Richard
Richard

Reputation: 16742

How do I set headers for an Rspec post?

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?

Upvotes: 0

Views: 1155

Answers (1)

Brian
Brian

Reputation: 5481

request.headers['password'] = 'x' is correct. In your controller, however, you should be inspecting request.headers and not just headers.

Upvotes: 2

Related Questions