Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting http headers RSpec 2.4 / Rails 3

I am getting started with RSpec. I have a new rails 3 app which uses the HTTP_ACCEPT_HEADER or the request 2 letter subdomain to set the application language and redirect accordingly. I am successfully testing my redirection code using Cucumber.

Now I want to write my controller specs and I need to set the request subdomain before my test.

In my cucumber steps, I can specify:

header 'HTTP_HOST', 'es.mysite.local'
visit '/'

But when I try to do this in a spec file

header 'HTTP_HOST', 'es.mysite.local'
get 'index'

I get this error:

Failure/Error: header 'HTTP_HOST', "es.mysite.local"
 LoadError:
   no such file to load -- action_controller/integration

Any clue on how to solve this?

like image 894
gdelfino Avatar asked Feb 09 '11 16:02

gdelfino


1 Answers

Try this:

request.env['HTTP_HOST'] = 'es.mysite.local'
get 'index'
like image 78
zetetic Avatar answered Sep 30 '22 14:09

zetetic