Skip to content

Instantly share code, notes, and snippets.

@stve
Created May 19, 2011 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stve/980707 to your computer and use it in GitHub Desktop.
Save stve/980707 to your computer and use it in GitHub Desktop.
OmniAuth cukes
Feature: Authentication
In order to attract interest and users to Futureish
As a product development team
I want users to login via twitter
So that they can create a Futureish account
Scenario: Authentication via Twitter
Given I am logged in on twitter
When I go to the homepage
And I follow "Login with Twitter"
Then I should see "Dashboard"
And I should be on the dashboard page
And I should not see "Login with Twitter"
And I should see "You are logged in as:"
And I should see "Sign Out"
And a user account should be created
Scenario: Invalid Authentication
Given I am a random loser
When I go to the homepage
And I follow "Login with Twitter"
Then I should be on the homepage
And I should see "denied authorization"
And I should see "Login with Twitter"
And I should not see "Sign Out"
Scenario: Signout
Given I am logged in
And I should see "Sign Out"
When I follow "Sign Out"
Then I should be on the homepage
And I should see "Login with Twitter"
And I should not see "Sign Out"
Given /^I am a random passerby$/ do
true
end
Given /^I am a random loser$/ do
OmniAuth.config.mock_auth[:twitter] = :authorization_denied
end
Given /^I am logged in$/ do
Given "I am logged in on twitter"
When "I go to the homepage"
And "I follow \"Login with Twitter\""
end
Then /^I should be redirected to the dashboard$/ do
visit(root_path)
last_response.should be_redirect
end
Given /^I am logged in on twitter$/ do
OmniAuth.config.test_mode = true
OmniAuth.config.mock_auth[:twitter] = OMNIAUTH_TWITTER_HASH
end
Then /^a user account should be created$/ do
User.where(:uid => OMNIAUTH_TWITTER_HASH['uid']).first.should be
end
@JCBarry
Copy link

JCBarry commented May 19, 2011

Neat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment