title: Rails, Capybara and subdomains: how to visit certain subdomain
body: <p>Rails 3, Cucumber 0.9.4, Capybara 0.4.0</p>
  
  <p>I want to test my features with subdomain. I found that solution:</p>
  
  <pre><code>Given /^I visit subdomain "(.+)"$/ do |sub|
    Capybara.default_host = "#{sub}.example.com" #for Rack::Test
    Capybara.app_host = "http://#{sub}.example.com:9887" if Capybara.current_driver == :culerity
  end
  </code></pre>
  
  <p>It works if I run <code>cucumber features/subdomain.feature</code> but it fails if I run <code>cucumber features</code>! It's unbelievable, but it's true. I logged current urls and it is <code>subdomain.example.com</code> for <code>cucumber features/subdomain.feature</code> and <code>www.example.com</code> for <code>cucumber features</code> for one scenario with </p>
  
  <pre><code>Scenario: subdomain scenario
    Given I visit subdomain "subdomain"
  </code></pre>
  
  <p>in both cases!</p>
  
  <p>I don't know the reason...</p>
  
  <p>Is there best way for testing subdomains with capybara?</p>