Skip to content

Instantly share code, notes, and snippets.

@romikoops
Created April 13, 2012 16:57
Show Gist options
  • Save romikoops/2378343 to your computer and use it in GitHub Desktop.
Save romikoops/2378343 to your computer and use it in GitHub Desktop.
Rspec configuration and acceptance test for quick integration with Social Networks
# -*- encoding : utf-8 -*-
require 'spec_helper'
OmniAuth.config.test_mode = true
OmniAuth.config.add_mock(:facebook, {:uid => '123545',
:info => { :email => '[email protected]',
:first_name => "First",
:last_name => "Last"}
})
OmniAuth.config.add_mock(:vkontakte, {:uid => '123545',
:info => { :first_name => "First",
:last_name => "Last"}
})
module IntegrationSpecHelper
def login_with_oauth(service = :facebook)
visit "/auth/#{service}"
end
end
RSpec.configure do |config|
config.include IntegrationSpecHelper
end
# -*- encoding : utf-8 -*-
require 'acceptance_helper'
feature "Social LogIn" do
scenario "Visitor should login via Facebook" do
login_with_oauth :facebook
page.should have_content('Ваш аккаунт создан через социальную авторизацию Facebook.')
end
scenario "Visitor should login via VKontakte", js: true do
login_with_oauth :vkontakte
page.should have_content('Для завершения регистрации через Vkontakte нам также необходимы дополнительные данные.')
within('#new_user') do
fill_in 'Email:', with: '[email protected]'
click_on('ЗАРЕГИСТРИРОВАТЬСЯ')
end
wait_until {page.text.include?('Добро пожаловать! Вы успешно зарегистрировались.') }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment