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.

Revisions

  1. qoyyim revised this gist Sep 6, 2010. 4 changed files with 3 additions and 1 deletion.
    File renamed without changes.
    File renamed without changes.
    2 changes: 1 addition & 1 deletion user_steps.rb → features/step_definitions/user_steps.rb
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@

    # 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::MockSession.create(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_SECRET_KEY'])
    @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(',') )
    2 changes: 2 additions & 0 deletions features/support/env.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    #require 'cucumber/rails/world'
    require 'facebooker/rails/cucumber'
  2. eladmeidar created this gist Feb 6, 2010.
    9 changes: 9 additions & 0 deletions manage_users.feature
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    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"
    6 changes: 6 additions & 0 deletions user.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    class User < ActiveRecord::Base

    def facebook_user
    @facebook_user_cache ||= Facebooker::User.new(self.facebook_id)
    end
    end
    14 changes: 14 additions & 0 deletions user_steps.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    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::MockSession.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