rails-devise-roles应用程序的Selenium 测试user-delete-spec.rb
并user-edit-spec.rb
在 Codeship 的 CI 中运行时似乎中断。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
这里出了什么问题,我该如何修改它以使测试通过?(澄清一下,我在这些页面上的本地部署中没有错误 500,也没有基于 rails-devise-roles 的应用程序的 Heroku 实时部署。)