# Settings request.domain for testing purposes

**URL:** <https://www.ruby-forum.com/t/settings-request-domain-for-testing-purposes/149531>\
**Category:** Rails\
**Created:** [September 25, 2008, 9:02pm UTC](https://www.ruby-forum.com/t/settings-request-domain-for-testing-purposes/149531 "2008-09-25T21:02:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [September 25, 2008, 9:02pm UTC](https://www.ruby-forum.com/t/settings-request-domain-for-testing-purposes/149531/1 "2008-09-25T21:02:55Z")

</div>

My app, relies on request.domain to display some data according to the  
domain.

However during RSpec tests, the request.domain is set to “test.host”. Is  
there a way I can manually set it for the test environment?

Thanks for your tip

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [September 26, 2008, 12:45am UTC](https://www.ruby-forum.com/t/settings-request-domain-for-testing-purposes/149531/2 "2008-09-26T00:45:54Z")

</div>

Hi,

On 25 Wrz, 21:02, Fernando P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> My app, relies on request.domain to display some data according to the  
> domain.
> 
> However during RSpec tests, the request.domain is set to “test.host”. Is  
> there a way I can manually set it for the test environment?

Yes, you can do that, for example I do it like this:

it “should do something”  
request.headers[“Host”] = “[microsoft.com](http://microsoft.com)”  
get :index  
response.should render\_template(“public/404.html”)  
response.headers[“Status”].should == “404 Not Found”  
end

Not all is required, but you get the idea ;).
