I\'m trying to write out tests for a controller of mine that takes in requests from external services. So far this is my test:
describe ApplyController do
cont
Ok this is pretty silly of rspec.
Custom headers in Request Specs
headers = {
'AUTH' => 'super secret key'
}
post '/api/some_action', { user_id: 1337 }.to_json, headers
And in your controller:
def some_action
token = request.headers['AUTH']
end
Custom headers in Controller Specs
headers = {
'AUTH' => 'super secret key'
}
post '/api/some_action', { user_id: 1337 }, headers
And in your controller:
def some_action
token = request.headers['rack.session']['AUTH']
end
Just sharing the differences I had between the two. I don't believe I have any special configuration in rspec or rails to have the two different spec types' headers to be placed differently.