Created
September 8, 2011 12:56
-
-
Save alexeckermann/1203329 to your computer and use it in GitHub Desktop.
OmniAuth testing in RSpec + Capybara
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
module OauthMocking | |
def login_with_oauth(provider = :twitter) | |
visit "/auth/#{provider}" | |
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
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