【发布时间】:2017-12-16 01:46:02
【问题描述】:
我添加了一个 gem recaptcha 并在我的注册和登录页面上实现了它。 但是我的测试用例很少失败。其中一个测试用例是:
require 'rails_helper'
feature 'User sessions', js: true do
let(:organisation) {
FactoryGirl.create(:organisation, email_domain: 'example.com')
}
let!(:user) {
FactoryGirl.create(:user,
email: 'mrbig@example.com',
password: 'password',
organisation: organisation)
}
scenario 'user signs in and out' do
visit new_user_session_path
expect(page).to have_content 'Log in'
fill_in 'Email', with: 'mrbig@example.com'
fill_in 'Password', with: 'WRONG'
click_on 'Log in'
expect(page).to have_content 'Invalid Email or password.'
fill_in 'Email', with: 'mrbig@example.com'
fill_in 'Password', with: 'password'
click_on 'Log in'
find('.MenuContent-logout').click
expect(page).to have_text 'Log in'
end
end
我已将Recaptcha.configuration.skip_verify_env.push("test") 添加到我的config/initializers/recaptcha.rb 文件中,但在我的构建中仍然失败。
我还补充了:
scenario 'user signs up' do
Users::RegistrationsController.any_instance.stub(:check_captcha).and_return(true)
# Begin signup
visit new_user_registration_path
但在这两种情况下,我都会遇到同样的错误:
【问题讨论】:
-
save_and_open_page将向您展示页面的外观,对调试很有用
标签: ruby-on-rails ruby rspec devise recaptcha