Skip to content

Instantly share code, notes, and snippets.

@nicalpi
Created September 7, 2011 11:48

Revisions

  1. nicalpi renamed this gist Sep 8, 2011. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. nicalpi revised this gist Sep 7, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion omniauth_helpers
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # You can read about this gist at:
    # You can read about this gist at: http://wealsodocookies.com/posts/how-to-test-facebook-login-using-devise-omniauth-rspec-and-capybara

    def set_omniauth(opts = {})
    default = {:provider => :facebook,
  3. nicalpi revised this gist Sep 7, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion omniauth_helpers
    Original file line number Diff line number Diff line change
    @@ -37,6 +37,6 @@ def set_invalid_omniauth(opts = {})
    }.merge(opts)

    OmniAuth.config.test_mode = true
    OmniAuth.config.mock_auth[credentials[:provider] = credentials[:invalid]
    OmniAuth.config.mock_auth[credentials[:provider]] = credentials[:invalid]

    end
  4. nicalpi revised this gist Sep 7, 2011. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions facebook_registration.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    background do
    set_omniauth()
    click_link_or_button 'Sign up with Facebook'
    end
  5. nicalpi revised this gist Sep 7, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions omniauth_helpers
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # You can read about this gist at:

    def set_omniauth(opts)
    def set_omniauth(opts = {})
    default = {:provider => :facebook,
    :uuid => "1234",
    :facebook => {
    @@ -30,7 +30,7 @@ def set_omniauth(opts)
    }
    end

    def set_invalid_omniauth(opts)
    def set_invalid_omniauth(opts = {})

    credentials = { :provider => :facebook,
    :invalid => :invalid_crendentials
  6. nicalpi revised this gist Sep 7, 2011. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions omniauth_helpers
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    # You can read about this gist at:

    def set_omniauth(opts)
    default = {:provider => :facebook,
    :uuid => "1234",
  7. nicalpi created this gist Sep 7, 2011.
    40 changes: 40 additions & 0 deletions omniauth_helpers
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    def set_omniauth(opts)
    default = {:provider => :facebook,
    :uuid => "1234",
    :facebook => {
    :email => "[email protected]",
    :gender => "Male",
    :first_name => "foo",
    :last_name => "bar"
    }
    }

    credentials = default.merge(opts)
    provider = credentials[:provider]
    user_hash = credentials[provider]

    OmniAuth.config.test_mode = true

    OmniAuth.config.mock_auth[provider] = {
    'uid' => credentials[:uuid],
    "extra" => {
    "user_hash" => {
    "email" => user_hash[:email],
    "first_name" => user_hash[:first_name],
    "last_name" => user_hash[:last_name],
    "gender" => user_hash[:gender]
    }
    }
    }
    end

    def set_invalid_omniauth(opts)

    credentials = { :provider => :facebook,
    :invalid => :invalid_crendentials
    }.merge(opts)

    OmniAuth.config.test_mode = true
    OmniAuth.config.mock_auth[credentials[:provider] = credentials[:invalid]

    end