-
-
Save qoyyim/566604 to your computer and use it in GitHub Desktop.
Cucumber for Facebooker
This file contains hidden or 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 'cucumber/rails/world' | |
| require 'facebooker/rails/cucumber' |
This file contains hidden or 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
| Feature: Manage users | |
| In order to use the application | |
| As a facebook user | |
| I want to login in and authorize | |
| Scenario: Register new user | |
| Given I am logged in as a Facebook user | |
| When I go to "the homepage" | |
| Then I should see "Welcome" |
This file contains hidden or 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
| class User < ActiveRecord::Base | |
| def facebook_user | |
| @facebook_user_cache ||= Facebooker::User.new(self.facebook_id) | |
| end | |
| end |
This file contains hidden or 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 am logged in as a Facebook user$/ do | |
| # Initializer facebooker session | |
| @integration_session = open_session | |
| @current_user = User.create! :facebook_id => 1 | |
| # User#facebook_user returns a Facebook::User instance, i decided to mock the session in here since i am not | |
| # sure what the behavior might be if it will be in the actual model. | |
| @current_user.facebook_user.session = Facebooker::Session.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY']) | |
| @current_user.facebook_user.friends = [ Facebooker::User.new(:id => 2, :name => 'Bob'), | |
| Facebooker::User.new(:id => 3, :name => 'Sam')] | |
| @integration_session.default_request_params.merge!( :fb_sig_user => @current_user.facebook_id, :fb_sig_friends => @current_user.facebook_user.friends.map(&:id).join(',') ) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment