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:
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 <top (required)>'
I read on the common build problems for Travis CI to use Capybara.default_wait_time = 15
; however, I either put that in the wrong place, or it doesn't work.
Example spec:
scenario 'User signs up with valid credentials' do
Capybara.default_wait_time = 15
visit '/users/sign_up'
fill_in 'Username', with: 'dannnnneh'
...
EDIT:
I have also tried putting Capybara.default_wait_time = 15
in rails_helper.rb
, spec_helper.rb
, spec/support/capybara.rb
.
I also added the following to .travis.yml
because of this SO question.
script:
- xvfb-run bundle exec rspec spec/features/*.rb
However, that did not work either.
Does anyone know what the probelm might be or how to fix it?
EDIT:
Here is my spec_helper.rb
:
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
bundle install
in your test script on travis? – DickieBoy