Appending headers to Rspec controller tests
I was able to fix it by using @request.env
instead of @request.headers
like so:
describe ApplyController do
context 'when valid' do
let(:parameters) do
file = File.join File.dirname(__FILE__), '..', 'samples', 'Indeed.json'
JSON.parse(File.read file)
end
let(:signature) { 'GC02UVj0d4bqa5peNFHdPQAZ2BI=' }
it 'returns 200 ok if Request is valid' do
@request.env['X-Indeed-Signature'] = signature
post :indeed, parameters
expect(response.status).to eq 200
end
end
end
I think you want (straight from one of your links)
it "returns 200 ok"
@request.headers['X-Indeed-Signature'] = signature
post :indeed, parameters
response.status.should == 200
end
You don't need subject(:response)