Answer the question
In order to leave comments, you need to log in
Why doesn't the oauth authorization test pass with the correct host?
The task is this: to test authorization through facebook.
Problem (message that pops up when testing after a click_on event):
Warning
Невозможно загрузить URL: Домен этого URL не включен в список доменов приложения. Чтобы загрузить этот URL, добавьте все домены и поддомены своего приложения в поле «Домены приложения» в настройках вашего приложения.
require 'acceptance_helper'
feature 'User sign in with oauth' do
scenario 'can sign in user with Facebook account', :js do
visit new_user_session_path
expect(page).to have_content('Sign in with Facebook')
mock_auth_hash_facebook
click_on 'Sign in with Facebook'
expect(page).to have_content I18n.t('devise.sessions.signed_in')
expect(current_path).to eq root_path
end
end
module OmniauthMacros
def mock_auth_hash_facebook
OmniAuth.config.mock_auth[:facebook] = {
provider: 'facebook',
uid: '1234567',
info: {
email: '[email protected]',
},
credentials: {
token: 'mock_token',
secret: 'mock_secret'
}
}
end
end
gem 'omniauth'
gem 'omniauth-facebook'
Answer the question
In order to leave comments, you need to log in
I found a solution to the problem, you just need to read the documentation better. In order for the mock to start working as a stub, you need to set it in the config before the test:
OmniAuth.config.test_mode = true
Information taken from: https://github.com/omniauth/omniauth/wiki/Integrat...
Use a real request to facebook during the execution of the tests is not necessary.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question