Making a request like so:
post :create, {}, { "X-BLAH" => "blah" }
ends up with a request object with the specified headers nested in "rack.session":
#<ActionController::TestRequest:0x105e02698 ... "rack.session"=>{"X-BLAH"=>"blah"} ... >
so, for instance, sending an HTTP_AUTHORIZATION header doesn't get picked up by authenticate_or_request_with_http_basic
.
I'm using the gems:
gem "rails", "3.0.0.beta3"
gem "rspec", "2.0.0.beta.9"
gem "rspec-rails", "2.0.0.beta.9.1"
Ben
ps. This didn't happen with rspec 2 beta4
As of beta.8, controller specs delegate to ActionController::TestCase::Behavior (http://github.com/rails/rails/blob/master/actionpack/lib/action_controller/test_case.rb).
To set headers, you set them directly on the request object:
request.env["X-BLAH"] = "blah" post :create, ....
Great, thanks for the quick reply. Where might I find documentation?
What about for request specs?
request
is coming up nil?
Thanks,
Dan
Woops looks like #request_via_redirect
does the trick
http://guides.rubyonrails.org/testing.html#helpers-available-for-integration-tests
Dan
Most helpful comment
What about for request specs?
request
is coming up nil?Thanks,
Dan