Created
January 7, 2014 21:16
-
-
Save jboursiquot/8307052 to your computer and use it in GitHub Desktop.
spec/features/authenticate_with_github_spec.rb
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
require 'spec_helper' | |
feature 'authenticate with github', %q{ | |
As a user | |
I want to authenticate | |
So that I can gain access to the system | |
}, authentication: true, | |
vcr: {cassette_name: 'github/auth'} do | |
# Acceptance Criteria | |
# * if my identity exists in the system and I'm authorized, grant me access | |
# * if my identity does not exist, but I'm authorized, prompt me to confirm profile | |
# * if I'm unauthorized, deny me access | |
# * when authentication with the provider fails, show an error | |
scenario 'valid, existant identity' do | |
bypass_authorization do | |
stub_auth_response(FactoryGirl.create(:user), :github) | |
visit '/' | |
click_link 'Sign In' | |
page.should have_content 'Hello!' | |
page.should have_content 'Sign Out' | |
end | |
end | |
scenario 'valid, nonexistant identity' do | |
bypass_authorization do | |
stub_auth_response(FactoryGirl.build(:user), :github) | |
visit '/' | |
click_link 'Sign In' | |
click_button 'Confirm Details' | |
page.should have_content 'Hello!' | |
end | |
end | |
scenario 'unauthorized identity' do | |
#do not bypass authorization | |
stub_auth_response(FactoryGirl.create(:user), :github) | |
visit '/' | |
click_link 'Sign In' | |
page.should have_content 'Sorry, we could not grant you access' | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment