Hi.
Recently I discovered a starange thing.
ActionDispatch::TestRequest instance doesn't contain
HTTP_ACCEPT header while been generated in controller specs:
RSpec.describe "Projects", :type => :controller do
describe FoosController do
describe "Get index" do
context "common" do
before do
get :index, nil, {'HTTP_ACCEPT' => 'application/json'} #doesn't affect at all, nothing to affect
end
...
end
end
end
end
Hence it's impossible to set this header during requests. The only solution I found is setting the header with @request.env in before block before issuing the request:
before do
@request.env['HTTP_ACCEPT'] = 'application/json'
...
end
Can anyone explain me why this is happening in controller specs? And is there another (better) way to set the header?
ActionDispatch::TestRequest