2017-07-11 42 views
0

gem recaptchaを追加して、サインアップとログインページに実装しました。 しかし、私のテストケースはほとんど失敗しています。テストケースの一つは次のとおりです。Recaptchaを追加した後にRSpecテストケースが失敗する

require 'rails_helper' 

feature 'User sessions', js: true do 
    let(:organisation) { 
    FactoryGirl.create(:organisation, email_domain: 'example.com') 
    } 

    let!(:user) { 
    FactoryGirl.create(:user, 
     email: '[email protected]', 
     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: '[email protected]' 
    fill_in 'Password', with: 'WRONG' 
    click_on 'Log in' 

    expect(page).to have_content 'Invalid Email or password.' 

    fill_in 'Email', with: '[email protected]' 
    fill_in 'Password', with: 'password' 
    click_on 'Log in' 

    find('.MenuContent-logout').click 

    expect(page).to have_text 'Log in' 
    end 
end 

私はconfig/initializers/recaptcha.rbファイルにRecaptcha.configuration.skip_verify_env.push("test")を追加しましたが、それでも、それは私のビルドに失敗します。

私も追加:

scenario 'user signs up' do 
Users::RegistrationsController.any_instance.stub(:check_captcha).and_return(true) 
# Begin signup 
visit new_user_registration_path 

しかし、両方のケースで、私は同じエラー取得しています:それは私のビルド環境での設定の問題だったよう

enter image description here

+0

は 'save_and_open_page'をデバッグするための有用な、ページがどのように見えるかを紹介しますのに役立ちます – usha

答えて

0

思えます。自分の環境変数にGoogleサービスのプライベートキーと公開キーを追加するのを忘れてしまった。

・ホープこれは誰か

関連する問題