-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4347cbb
commit 404b1cf
Showing
1 changed file
with
33 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,39 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe "OmniauthGoogles", type: :system do | ||
RSpec.describe 'OmniauthGoogles', type: :system do | ||
before do | ||
driven_by(:rack_test) | ||
driven_by(:selenium_chrome_headless) | ||
|
||
OmniAuth.config.test_mode = true | ||
Rails.application.env_config['devise.mapping'] = Devise.mappings[:user] | ||
Rails.application.env_config['omniauth.auth'] = google_oauth2_mock | ||
end | ||
|
||
after do | ||
OmniAuth.config.test_mode = false | ||
end | ||
|
||
pending "add some scenarios (or delete) #{__FILE__}" | ||
let 'google_oauth2_mock' do | ||
OmniAuth.config.mock_auth[:google_oauth2] = OmniAuth::AuthHash.new({ | ||
provider: 'google_oauth2', | ||
uid: '12345678910', | ||
info: { | ||
email: 'testing@gmail-fake.com', | ||
first_name: 'taro', | ||
last_name: 'test' | ||
}, | ||
credentials: { | ||
token: 'abcdefgh12345', | ||
refresh_token: '12345abcdefgh', | ||
expires_at: DateTime.now | ||
} | ||
}) | ||
end | ||
|
||
scenario 'authorizes and sets user currently in database with Google OAuth' do | ||
visit user_session_path | ||
expect(page).to have_text 'Googleでログイン' | ||
click_on 'Googleでログイン' | ||
expect(page).to have_selector '#flash', text: 'Google アカウントによる認証に成功しました。' | ||
end | ||
end |