Created
December 9, 2010 17:53
-
-
Save rodrigoflores/735058 to your computer and use it in GitHub Desktop.
This file contains 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
#Omniauth initializer | |
module OmniAuth | |
module Strategy #:nodoc: | |
def initialize(app, name, *args) | |
@app = app | |
@name = name.to_sym | |
@options = args.last.is_a?(Hash) ? args.pop : {} | |
yield self if block_given? | |
end | |
end | |
end | |
module OmniAuth | |
mattr_accessor :facebook_strategy | |
@@facebook_strategy = nil | |
end | |
# config/environment.rb | |
middleware.use Facebook, "FOO", "BAR" do |strategy| | |
OmniAuth.facebook_strategy = strategy | |
end | |
# integration test | |
FACEBOOK_INFO = { | |
:id => '12345', | |
:link => 'http://facebook.com/josevalim', | |
:email => '[email protected]', | |
:first_name => 'Jose', | |
:last_name => 'Valim', | |
:website => 'http://blog.plataformatec.com.br' | |
} | |
ACCESS_TOKEN = { | |
:access_token => "plataformatec" | |
} | |
stubs = Faraday::Adapter::Test::Stubs.new do |b| | |
b.post('/oauth/access_token') { [200, {}, ACCESS_TOKEN.to_json] } | |
b.get('/me?access_token=plataformatec') { [200, {}, FACEBOOK_INFO.to_json] } | |
end | |
OmniAuth.facebook_strategy.client.connection.build do |b| | |
b.adapter :test, stubs | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment