Skip to content

Instantly share code, notes, and snippets.

@alexeckermann
Created September 8, 2011 12:56
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save alexeckermann/1203329 to your computer and use it in GitHub Desktop.
Save alexeckermann/1203329 to your computer and use it in GitHub Desktop.
OmniAuth testing in RSpec + Capybara
module OauthMocking
def login_with_oauth(provider = :twitter)
visit "/auth/#{provider}"
end
end
RSpec.configure do |config|
# ...
OmniAuth.config.test_mode = true
omniauth_hash = { 'uid' => '12345', 'nickname' => 'testuser', 'credentials' => { 'token' => 'umad', 'secret' => 'bro?' } }
OmniAuth.config.add_mock(:twitter, omniauth_hash)
OmniAuth.config.add_mock(:foursquare, omniauth_hash)
OmniAuth.config.add_mock(:facebook, omniauth_hash.merge({'nickname' => 'Mr Herpy Derpy Pants'})) # Facebook has 'real-user' attributes, add them here if need be
# ...
config.include OauthMocking
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment