[rspec-users] nested route not receiving :id parameter within controller spec

Andrew Timberlake andrew at andrewtimberlake.com
Mon Feb 6 22:39:15 EST 2012


The id belongs to post so your test line should be: 
post :share, :post_id => @post.id

Andrew  

On Tuesday 07 February 2012 at 3:45 AM, Patrick J. Collins wrote:

> I've got a share method in my controller, and I have the following spec:
> 
> describe PostsController do
> 
> describe "#share" do
> 
> it "doesn't blow up" do
> post :share, :id => @post.id
> end
> 
> # ... etc
> 
> And... It blows up!
> 
> Failures:
> 
> 1) PostsController#share shares
> Failure/Error: post :share
> ActionController::RoutingError:
> No route matches {:controller=>"posts", :action=>"share"}
> # ./spec/controllers/posts_controller_spec.rb:7
> 
> My routes has:
> 
> resources :posts do
> post :share, :on => :member
> end
> 
> rake routes shows:
> 
> share_post POST /posts/:id/share(.:format) {:action=>"share", :controller=>"posts"}
> 
> ...
> 
> Why is it ignoring the :id parameter in my test and therefore blowing up?
> 
> Thanks.
> 
> Patrick J. Collins
> http://collinatorstudios.com
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org (mailto:rspec-users at rubyforge.org)
> http://rubyforge.org/mailman/listinfo/rspec-users
> 
> 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20120207/fa136115/attachment.html>


More information about the rspec-users mailing list