title: rspec capybara - subdomain tests
body: <p>When I create integration tests with capybara/rspec it seems to get the correct url and paths. But it errors out on the 'click_button'.</p>
  
  <p>Note: 'puts current_url' returns the correct path: <a href="http://StoreName1.lvh.me/login" rel="nofollow">http://StoreName1.lvh.me/login</a></p>
  
  <p><strong>Test:</strong></p>
  
  <pre><code>require 'spec_helper'
  
  describe "Account access" do
  
    before(:each) do
      Factory(:plan)
      Factory(:theme)
      @account = Factory(:account)
      set_host("#{@account.url}")
      end
  
    describe "GET /login" do
      it "should not sign in for invalid details" do
        Factory(:account, :url =&gt; 'dan', :email =&gt; 'dan@example.com')
        visit "/login"
        page.should have_content("Sign in to your store")
        fill_in "email", with: "bob@example.com"
        fill_in "password", with: "donuts"
        click_button 'Sign in'
      end
  
    end
  
      def set_host(host)
      host! host
      Capybara.app_host = "http://" + host + ".lvh.me"
      end
  
  end
  </code></pre>
  
  <p><strong>Error Log:</strong></p>
  
  <pre><code>  1) Account access GET /login should not sign in for invalid details
       Failure/Error: click_button 'Sign in'
       ActiveRecord::RecordNotFound:
         Couldn't find Account with url = StoreName1
       # ./app/controllers/application_controller.rb:11:in `get_account_info'
       # (eval):2:in `click_button'
       # ./spec/requests/accounts_spec.rb:19:in `block (3 levels) in &lt;top (required)&gt;'
  </code></pre>