On Fri, Sep 11, 2009 at 3:28 PM, Giuseppe Bertini <[email protected]> wrote: > Hello list, > this should be an easy one, but I seem to be stuck. > What is the proper way to mimic a POST request for a named, non-RESTful > route? > > here's the route and the rest of the setup: > > map.accept_invitation '/accept_invitation/:id', :controller => > "invitations", :action => "accept", :method => "post" > > class InvitationsController < ApplicationController > def accept > end > end > > describe InvitationsController do > describe "POST 'accept'" do > it "should be successful" do > post :accept, :id => 1 > response.should be_success > end > end > end > > When I run this spec, I get: > No route matches {:controller=>"invitations", :action=>"accept", > :id=>"1"}
I just fired up a brand new rails app and copied the above into config/routes.rb, app/controllers/invitations_controller.rb, and spec/controllers/invitations_controller_spec.rb, ran the spec and it passed with flying color (green). I'm using rails-2.3.4, ruby-1.8.7, rspec-1.2.8 and rspec-rails-1.2.7.1. Which versions are you using? Cheers, David > > Can anyone please suggest what I should be writing instead to test this > request? > > Thanks in advance! > Giuseppe > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > [email protected] > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ rspec-users mailing list [email protected] http://rubyforge.org/mailman/listinfo/rspec-users
