Skip to content

Instantly share code, notes, and snippets.

@qoyyim
Forked from eladmeidar/manage_users.feature
Created September 6, 2010 03:30
Show Gist options
  • Select an option

  • Save qoyyim/566604 to your computer and use it in GitHub Desktop.

Select an option

Save qoyyim/566604 to your computer and use it in GitHub Desktop.
Cucumber for Facebooker
#require 'cucumber/rails/world'
require 'facebooker/rails/cucumber'
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"
class User < ActiveRecord::Base
def facebook_user
@facebook_user_cache ||= Facebooker::User.new(self.facebook_id)
end
end
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