Rails 3, RSpec 2:
In my rspec test for a controller, I’m using post and pass in some parameters:
it "returns a job id" do
post :new, { :a => 'b'}
response.status.should == 200
end
This works fine and in the controller params[:a] is 'b'
However, request.url on the controller side is http://localhost/controller?a=b
I don’t want to have the parameters in the URL since in a real scenario (outside test) the URL is part of a security signature.
My question is why rspec post adds the parameters to the URL instead of behaving the same way as a POST in a browser (or CURL)?
I haven’t found an answer for this yet, but here is how I managed to solve the problem so my unit tests work: I simple by-pass signature checking when running unit tests. Here is the code: