1
0
Fork 0
mirror of https://github.com/nov/fb_graph2 synced 2023-03-27 23:22:15 -04:00

auth_spec

This commit is contained in:
nov 2014-09-01 13:23:54 +09:00
parent d2696e4d32
commit a569bc48a1
4 changed files with 32 additions and 6 deletions

View file

@ -0,0 +1,25 @@
require 'spec_helper'
describe FbGraph2::Auth do
describe '.app' do
subject { instance }
let(:instance) { FbGraph2::Auth.new 'client_id', 'client_secret' }
it { should be_a Rack::OAuth2::Client }
describe 'fb_exchange_token grant' do
it do
instance.fb_exchange_token = 'short_lived_access_token'
access_token = mock_graph :post, 'oauth/access_token', 'token_response', params: {
grant_type: 'fb_exchange_token',
fb_exchange_token: 'short_lived_access_token',
client_id: 'client_id',
client_secret: 'client_secret'
}, disable_api_versioning: true do
instance.access_token!
end
access_token.should be_instance_of Rack::OAuth2::AccessToken::Legacy
end
end
end
end

View file

@ -22,7 +22,7 @@ describe FbGraph2::Node do
it 'should use api_version globally' do
expect do
instance.fetch
end.to request_to 'v2.x/identifier', :get, api_version_in_path: true
end.to request_to 'v2.x/identifier', :get, disable_api_versioning: true
end
end
@ -30,7 +30,7 @@ describe FbGraph2::Node do
it 'should use api_version globally' do
expect do
instance.edge :foo
end.to request_to 'v2.x/identifier/foo', :get, api_version_in_path: true
end.to request_to 'v2.x/identifier/foo', :get, disable_api_versioning: true
end
end
end
@ -40,7 +40,7 @@ describe FbGraph2::Node do
it 'should use api_version locally' do
expect do
instance.fetch nil, api_version: 'v2.y'
end.to request_to 'v2.y/identifier', :get, api_version_in_path: true
end.to request_to 'v2.y/identifier', :get, disable_api_versioning: true
FbGraph2.api_version.should == @original
end
end
@ -49,7 +49,7 @@ describe FbGraph2::Node do
it 'should use api_version locally' do
expect do
instance.edge :foo, {}, api_version: 'v2.y'
end.to request_to 'v2.y/identifier/foo', :get, api_version_in_path: true
end.to request_to 'v2.y/identifier/foo', :get, disable_api_versioning: true
FbGraph2.api_version.should == @original
end
end

View file

@ -0,0 +1 @@
access_token=access_token&expires=5183975

View file

@ -14,7 +14,7 @@ module MockGraph
response = yield
a_request(
method,
endpoint_for(path)
endpoint_for(path, options)
).with(
request_for(method, options)
).should have_been_made.once
@ -40,7 +40,7 @@ module MockGraph
private
def endpoint_for(path, options = {})
api_version = unless options[:api_version_in_path]
api_version = unless options[:disable_api_versioning]
options[:api_version] || FbGraph2.api_version
end
File.join FbGraph2.root_url, api_version.to_s, path