Sha256: 880710dd47c0fea2f0c63d22ef8fd0740b29e945df29d841dacb335f3356993a

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 KB

Contents

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

    context 'when error occured' do
      it do
        expect do
          mock_graph :post, 'oauth/access_token', 'error/400/191', status: [400, 'Bad Request'], disable_api_versioning: true do
            instance.authorization_code = 'auth_code'
            instance.access_token!
          end
        end.to raise_error(FbGraph2::Exception) do |e|
          e.message.should == 'Missing redirect_uri parameter.'
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fb_graph2-0.3.2 spec/fb_graph2/auth_spec.rb
fb_graph2-0.3.1 spec/fb_graph2/auth_spec.rb
fb_graph2-0.3.0 spec/fb_graph2/auth_spec.rb
fb_graph2-0.2.0 spec/fb_graph2/auth_spec.rb
fb_graph2-0.1.3 spec/fb_graph2/auth_spec.rb