I'm using RSpec (through the gem rspec-rails) for testing and developing my application. I've tried to "test" a controller and run up against a strange behavior of post and get methods (same for all the others of this kind).
In my route file:
controller :sessions do post '/login', action: :login_create get '/login', action: :login get '/logout', action: :logout end At the beginning, I was thinking that post will simulate an http post request at the specified url, so I've wrote in my spec:
describe "POST 'login'" do it "returns http success" do post 'login' response.should be_success response.should render_template 'sessions/login_create' end end But this will call the login action, not the login_create, and then the last assert fail. After a lot of googling and experiments, I've changed post 'login' with post :login_create and this actually works! The strange thing is that also if I change post with get, it will continue to work! O_o Isn't this strange? How this methods are intended to work and to be used?
In the Rails API I've not found anything else than the class: ActionController::TestCase::Behavior