I have a Rails 3.1 application that is created as a RESTful API. The plan is to handle authentication based on the API key, which is transmitted for each request through an HTTP authorization header. To test this in RSpec, I wanted to set the request.env["HTTP_AUTHORIZATION"] attribute in the config.before block:
RSpec.configure do |config| config.mock_with :rspec config.use_transactional_fixtures = true config.before(:each) do
Unfortunately, this throws an exception because the request object does not exist in the config.before block.
Is there any other approach to setting this header outside of inclusion in the before block of each controller test file?
Hector castro
source share