title: Specs pass locally, but fail for Travis CI
body: <p>I wrote some feature specs to test logging in through my rails app, and the specs all pass locally, but they fail when Travis CI runs them. Here is an example:</p>
  
  <pre><code>1) User Registration User signs up with valid credentials
       Failure/Error: fill_in 'Username', with: 'dannnnneh'
       Capybara::ElementNotFound:
         Unable to find field "Username"
       # ./spec/features/registrations_controller_spec.rb:8:in `block (2 levels) in &lt;top (required)&gt;'
  </code></pre>
  
  <p>I read on the <a href="http://docs.travis-ci.com/user/common-build-problems/#Capybara%3A-I%E2%80%99m-getting-errors-about-elements-not-being-found" rel="nofollow noreferrer">common build problems for Travis CI</a> to use <code>Capybara.default_wait_time = 15</code>; however, I either put that in the wrong place, or it doesn't work.</p>
  
  <p>Example spec:</p>
  
  <pre><code>scenario 'User signs up with valid credentials' do
      Capybara.default_wait_time = 15
      visit '/users/sign_up'
      fill_in 'Username', with: 'dannnnneh'
      ...
  </code></pre>
  
  <p>EDIT: </p>
  
  <p>I have also tried putting <code>Capybara.default_wait_time = 15</code> in <code>rails_helper.rb</code>, <code>spec_helper.rb</code>, <code>spec/support/capybara.rb</code>.</p>
  
  <p>I also added the following to <code>.travis.yml</code> because of <a href="https://stackoverflow.com/questions/20713471/capybaraelementnotfound-on-all-specs-only-on-travis?rq=1">this</a> SO question.</p>
  
  <pre><code>script:
      - xvfb-run bundle exec rspec spec/features/*.rb
  </code></pre>
  
  <p>However, that did not work either.</p>
  
  <p>Does anyone know what the probelm might be or how to fix it?</p>
  
  <p>EDIT:</p>
  
  <p>Here is my <code>spec_helper.rb</code>:</p>
  
  <pre><code>require 'simplecov'
  SimpleCov.start
  
  
  require 'capybara'
  require 'capybara/poltergeist'
  
  Capybara.javascript_driver = :poltergeist
  Capybara.register_driver :poltergeist do |app|
    Capybara::Poltergeist::Driver.new(app, timeout: 15)
  end
  
  RSpec.configure do |config|
  
    config.expect_with :rspec do |expectations|
      expectations.include_chain_clauses_in_custom_matcher_descriptions = true
    end
  
    config.mock_with :rspec do |mocks|
      mocks.verify_partial_doubles = true
    end
  
  end
  </code></pre>