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
Can you post your spec_helper ? Also, the official documentation suggests another way to configure xvfb, have you checked http://docs.travis-ci.com/user/gui-and-headless-browsers/ ?
Check whether TrevisCI can create test DB.
For working with Travis CI, I had to create public test DB
which TravisCI can use...
You have some problem or other, but no debug output, so it's hard to tell what's wrong. I would eliminate the issues one by one by altering your tests to give you that output. You could have one of the following (or something else):
Try adding a step that validates the page you are on:
expect(page).to have_current_path('/users/sign_up')
Or try adding a step that prints out the HTML for the page.
puts page.html
or if not...
fail page.html
You should find something of use to tell you why you cannot see the input you want to fill in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With