Created
September 11, 2018 08:48
-
-
Save bernardo-cs/6f87deb2aa2664bbdaf8045b6c682549 to your computer and use it in GitHub Desktop.
Creates new facebook test user with koala gem. Signs in user on facebook.com. Accepts facebook "continue as #{username}" iframe.
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
# frozen_string_literal: true | |
require 'application_system_test_case' | |
class FacebookLoginTest < ApplicationSystemTestCase | |
# create new test user with Koala Gem | |
def setup | |
@test_users = Koala::Facebook::TestUsers.new | |
@user = @test_users.create(false) | |
login_in_facebook(@user) | |
end | |
def teardown | |
@test_users.delete(@user) | |
end | |
def test_login_with_facebook | |
visit spa_page_with_facebook_login_url | |
# on your app click on the "Login with facebook" button | |
facebook_login_window = window_opened_by do | |
click_on 'Login with facebook' | |
end | |
# click on "continue as USERNAME" on the facebook iframe | |
within_window(facebook_login_window) do | |
find(:xpath, "//button[contains(@name, '__CONFIRM__')]").click | |
end | |
end | |
private | |
# Logs in test user on facebook.com | |
def login_in_facebook(user) | |
Capybara.always_include_port = false | |
visit 'https://www.facebook.com' | |
fill_in :email, with: user['email'] | |
fill_in :pass, with: user['password'] | |
find('#loginbutton').click | |
Capybara.always_include_port = true | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment