Created
November 15, 2010 02:42
-
-
Save ngw/676354 to your computer and use it in GitHub Desktop.
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
Given /^I'm a new user$/ do | |
# Nothing to do here | |
end | |
Given /^I am an existing user$/ do | |
@user = User.create( :email => 'test@example.com', :subdomain => 'example', :fb_access_token => 'abcde12345' ) | |
end | |
When /^I log in using Facebook$/ do | |
@facebook = double( 'facebook' ) | |
Koala::Facebook::OAuth.should_receive( :new ).and_return( @facebook ) | |
@facebook.should_receive( :url_for_oauth_code ).and_return( facebook_callback_url( :code => 'abcd' ) ) | |
visit( '/sign_in' ) | |
@facebook.should_receive( :get_access_token ).with( 'abcd' ).and_return( "abcde12345" ) | |
@graph = double( 'graph' ) | |
Koala::Facebook::GraphAPI.should_receive( :new ).with( "abcde12345" ).and_return( @graph ) | |
me = { 'location' => { 'name' => 'Seattle' }, 'first_name' => 'John', 'last_name' => 'Doe', | |
'gender' => 'male', 'birthday' => Date.new( 1978, 12, 19 ), | |
'email' => 'test@example.com', 'website' => 'http://example.com' } | |
@graph.should_receive( :get_object ).with( 'me' ).and_return( me ) | |
click_link( 'Sign in with Facebook' ) | |
end | |
Then /^I should confirm my data$/ do | |
current_url.should == facebook_callback_url( :code => 'abcd' ) | |
find_field( "user[given_name]" ).value.should == 'John' | |
find_field( "user[family_name]" ).value.should == 'Doe' | |
# FIXME: geolocation | |
find_field( "user[location]" ).value.should == 'Seattle' | |
find_field( "user[gender]" ).value.should == 'male' | |
# FIXME: standardize representation | |
find_field( "user[birthday]" ).value.should == '1978-12-19' | |
find_field( "user[email]" ).value.should == 'test@example.com' | |
find_field( "user[url]" ).value.should == 'http://example.com' | |
fill_in "user[subdomain]", :with => 'example' | |
click_button( "Save" ) | |
end | |
Then /^I should be redirected to my dashboard$/ do | |
current_url.should == 'http://example.example.com/dashboard' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment