title: Rails, test mailer url
body: <p>My application sends E-mails containing absolute urls.</p>
  
  <p>I set host in config/environment/development.rb</p>
  
  <pre><code>config.action_mailer.default_url_options = { :host =&gt; 'localhost:3000' }
  </code></pre>
  
  <p>Now I want to test if Email contains valid url. Using regular expression I take out full url from E-mail and want to visit this address using Capybara function.</p>
  
  <pre><code>mail = ActionMailer::Base.deliveries.last
  address = mail.body.to_s[%r{http.+/edit}]
  visit address;
  </code></pre>
  
  <p>But I don't know what host should be set in config/environment/test.rb</p>
  
  <p>When I set localhost:3000 it tries to connect to my local server started by <code>rails server</code> command.</p>
  
  <p>Do you have any ideas to solve this problem?</p>