Question about finding correct url while running Rspec


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 ""
However, the objects are not saved in the test server and REST calls fail.

app.root_url gives:
<a href="" title=""></a>

3. How can I know (is there any variable) that the code is being run
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="" title=""></a>
<a href="" title=""></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!