Reputation: 16742
In my Rspec controller test function I've tried all the following:
post('pay', {p: 'x'}, password: 'x')
post('pay', {p: 'x'}, {password: 'x'})
,
request.headers['password'] = 'x'; post('pay', {p: 'x'})
None sends headers - in my controller I can't see any headers when saying puts headers.inspect
. (But the param p
is received correctly.)
How do you set headers in Rspec?
ActionController::Base
. require spec_helper
(and I tried without it)Upvotes: 0
Views: 1155
Reputation: 5481
request.headers['password'] = 'x'
is correct. In your controller, however, you should be inspecting request.headers
and not just headers
.
Upvotes: 2