添加Recaptcha后RSpec测试用例失败

时间:2017-07-11 20:33:38

标签: ruby-on-rails ruby rspec devise recaptcha

我添加了一个gem recaptcha并在我的注册和登录页面上实现了它。 但我的测试用例很少失败。其中一个测试案例是:

let normalMenuItems:[MenuItem] = [
    MenuItem(title: "My Teeups", icon: UIImage.teeup!, selected: true),
    MenuItem(title: "Discover", icon: UIImage.discover!),
    MenuItem(title: "Contacts", icon: UIImage.contacts!),
    .divider,
     MenuItem(title: "Research", icon: UIImage.send!).addTarget(self, action: #selector(goToContacts), for: .touchUpInside),.divider,
    MenuItem(title: "Settings", icon: UIImage.settings!),
    MenuItem(title: "Help", icon: UIImage.help!),
    MenuItem(title: "Send Feedback", icon: UIImage.feedback!)
]

我已将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

但在这两种情况下我都得到同样的错误:

enter image description here

1 个答案:

答案 0 :(得分:0)

似乎这是我的构建环境中的配置问题。我忘了将google服务中的私钥和公钥添加到我的环境变量中。

希望这有助于某人