DevHeads.net

Question about finding correct url while running Rspec

Hi,

I am new to Ruby and have a question about getting the correct url while
running rspecs.

The tests I am running make some REST calls and check if correct dynamic
files were loaded. I have a very generic question though:

Rails 4.0.5
ruby 2.1.0p0 (2013-12-25 revision 44422)
'rspec-rails' 2.14.1'

1. While developing the tests I am running code locally using
rspec spec/testfile.rb

By default the code runs in "test" environment and Rails.env prints test.

2. When I make the Rest calls using config file:
@url = YAML.load_file(Rails.root.join('config', 'urls.yml'))[Rails.env]

The call is directed to test endpoint correctly:
RestClient.get "http://example-test.com/apps/test/8"
However, the objects are not saved in the test server and REST calls fail.

app.root_url gives:
<a href="http://www.example.com/" title="http://www.example.com/">http://www.example.com/</a>

3. How can I know (is there any variable) that the code is being run
locally?
What changes should I make to the configuration file so tests can be run
locally and on test servers without hard coding ?

4. okay. I found some links
<a href="http://stackoverflow.com/questions/598933/how-do-i-change-the-default-www-example-com-domain-for-testing-in-rails" title="http://stackoverflow.com/questions/598933/how-do-i-change-the-default-www-example-com-domain-for-testing-in-rails">http://stackoverflow.com/questions/598933/how-do-i-change-the-default-ww...</a>
<a href="http://stackoverflow.com/questions/11712810/why-does-log-test-log-show-http-www-example-com-in-the-redirected-to-me" title="http://stackoverflow.com/questions/11712810/why-does-log-test-log-show-http-www-example-com-in-the-redirected-to-me">http://stackoverflow.com/questions/11712810/why-does-log-test-log-show-h...</a>

Looks like for rspec I have to do some configuration changes.
Can someone tell me in which file do I set the host name and how?

Thank you very much!

Regards,
Meenakshi