ruby-on-rails – 规格本地传递,但Travis CI失败

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 规格本地传递,但Travis CI失败前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我写了一些功能规格来测试通过我的rails应用程序登录,并且规范都在本地传递,但是当Travis CI运行它们时,它们会失败.这是一个例子:
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)>'

我在common build problems for Travis CI上阅读使用Capybara.default_wait_time = 15;但是,我或者把它放在错误的地方,否则就不行.

示例说明:

scenario 'User signs up with valid credentials' do
    Capybara.default_wait_time = 15
    visit '/users/sign_up'
    fill_in 'Username',with: 'dannnnneh'
    ...

编辑:

我也试过把capybara.default_wait_time = 15放在rails_helper.rb,spec_helper.rb,spec / support / capybara.rb中.

由于this SO问题,我还将以下内容添加到.travis.yml中.

script:
    - xvfb-run bundle exec rspec spec/features/*.rb

但是,这也不行.

有人知道这个问题可能是什么,还是怎么解决呢?

编辑:

这是我的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

解决方法

你能发布你的spec_helper吗此外,官方文档还提供了另一种配置xvfb的方法,是否已经检查了 http://docs.travis-ci.com/user/gui-and-headless-browsers/
原文链接:https://www.f2er.com/ruby/271545.html

猜你在找的Ruby相关文章