Codeship 在 rails-devise-roles 测试中中断

Codeship breaks on rails-devise-roles tests

当在 Codeship 的 CI 中 运行 时,rails-devise-roles 应用程序对 user-delete-spec.rbuser-edit-spec.rb 的 Selenium 测试似乎中断了。 rspec 在我的本地机器上运行良好,但在 Codeship 中中断。

我得到的rspec输出如下:

Failures:

1) User delete user can delete own account
Failure/Error: visit edit_user_registration_path(user)

Selenium::WebDriver::Error::ServerError:
  status code 500
# /home/rof/cache/bundler/ruby/2.3.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/response.rb:72:in `assert_ok'
# /home/rof/cache/bundler/ruby/2.3.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/response.rb:32:in `initialize'
# /home/rof/cache/bundler/ruby/2.3.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/http/common.rb:83:in `new'
# /home/rof/cache/bundler/ruby/2.3.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/http/common.rb:83:in `create_response'
# /home/rof/cache/bundler/ruby/2.3.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/http/default.rb:107:in `request'
# /home/rof/cache/bundler/ruby/2.3.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/http/common.rb:61:in `call'
# /home/rof/cache/bundler/ruby/2.3.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/w3c_bridge.rb:640:in `execute'
# /home/rof/cache/bundler/ruby/2.3.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/w3c_bridge.rb:114:in `create_session'
# /home/rof/cache/bundler/ruby/2.3.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/w3c_bridge.rb:76:in `initialize'
# /home/rof/cache/bundler/ruby/2.3.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/firefox/w3c_bridge.rb:45:in `initialize'
# /home/rof/cache/bundler/ruby/2.3.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/common/driver.rb:52:in `new'
# /home/rof/cache/bundler/ruby/2.3.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/common/driver.rb:52:in `for'
# /home/rof/cache/bundler/ruby/2.3.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver.rb:88:in `for'
# /home/rof/cache/bundler/ruby/2.3.0/gems/capybara-2.14.0/lib/capybara/selenium/driver.rb:22:in `browser'
# /home/rof/cache/bundler/ruby/2.3.0/gems/capybara-2.14.0/lib/capybara/selenium/driver.rb:62:in `visit'
# /home/rof/cache/bundler/ruby/2.3.0/gems/capybara-2.14.0/lib/capybara/session.rb:269:in `visit'
# /home/rof/cache/bundler/ruby/2.3.0/gems/capybara-2.14.0/lib/capybara/dsl.rb:50:in `block (2 levels) in <module:DSL>'
# ./spec/features/users/user_delete_spec.rb:21:in `block (2 levels) in <top (required)>'

2) User edit user changes email address
Failure/Error: visit edit_user_registration_path(user)

Selenium::WebDriver::Error::ServerError:
  status code 500
# [removed stack trace]

3) User edit user cannot cannot edit another user's profile
Failure/Error: visit edit_user_registration_path(other)

Selenium::WebDriver::Error::ServerError:
  status code 500
# [removed stack trace]

Finished in 23.21 seconds (files took 2.99 seconds to load)
31 examples, 3 failures

Failed examples:

rspec ./spec/features/users/user_delete_spec.rb:18 # User delete user can delete own account
rspec ./spec/features/users/user_edit_spec.rb:18 # User edit user changes email address
rspec ./spec/features/users/user_edit_spec.rb:45 # User edit user cannot cannot edit another user's profile

这是失败场景之一的示例:

scenario 'user can delete own account' do
    # skip 'skip a slow test' [removed from the original file]
    user = FactoryGirl.create(:user)
    login_as(user, :scope => :user)
    visit edit_user_registration_path(user)
    click_button 'Cancel my account'
    page.driver.browser.switch_to.alert.accept
    expect(page).to have_content I18n.t 'devise.registrations.destroyed'
end

这里出了什么问题,我该如何修改才能使测试通过? (需要澄清的是,我在这些页面上的本地部署以及基于 rails-devise-roles 的应用程序的 Heroku 实时部署都没有错误 500。)

联系了 Codeship 支持,他们非常乐于助人,并告诉我这是 Firefox 和适用于 Firefox 的 geckodriver 的问题,需要在 Codeship VM 上更新。如果其他人也有这个问题,使其工作的代码如下:

export FIREFOX_VERSION=53.0.3
curl -sSL https://raw.githubusercontent.com/codeship/scripts/master/packages/firefox.sh | bash -s
export GECKODRIVER_VERSION=0.17.0
source /dev/stdin <<< "$(curl -sSL https://raw.githubusercontent.com/codeship/scripts/master/languages/rust.sh)"
curl -sSL https://raw.githubusercontent.com/codeship/scripts/master/packages/geckodriver.sh | bash -s

非常感谢 Codeship 支持团队的 Joe Siewert 为我解决了这个问题!