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

Patrick J. Collins patrick at collinatorstudios.com
Mon Feb 6 20:45:30 EST 2012


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


More information about the rspec-users mailing list