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
--
You received this message because you are subscribed to the Google Groups
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rspec/72391f6a-c4e1-46ab-821d-349a89c22ec4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.