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@rubyforge.org (mailto:rspec-users@rubyforge.org)
> http://rubyforge.org/mailman/listinfo/rspec-users
> 
> 


_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to