Sha256: f1566fdb6022aedbd5bc604b2ae93dc1392ca2ed7710272ccd2665608df360f0

Contents?: true

Size: 1.75 KB

Versions: 3

Compression:

Stored size: 1.75 KB

Contents

require File.expand_path('../../../spec_helper', __FILE__)

describe FBGraph do
  describe FBGraph::Authorization do

    before :each do
      @client_id = 'client_id'
      @secret_id = 'secret_id'
      @client = FBGraph::Client.new(:client_id => @client_id,
                                    :secret_id => @secret_id)
      @authorization = FBGraph::Authorization.new(@client)
    end

    describe 'initialization' do
      it 'should set the client' do
        @authorization.instance_variable_get("@client").should == @client
      end
    end

    describe "instance methods" do
      describe '.authorize_url' do
        it 'should return the authorization url' do
          @authorization.authorize_url(:redirect_uri => 'redirect/to/path' , 
                                       :scope => 'email,user_photos,friends_photos').should == "https://graph.facebook.com/oauth/authorize?response_type=code&client_id=client_id&redirect_uri=redirect%2Fto%2Fpath&scope=email%2Cuser_photos%2Cfriends_photos"
        end
      end
      describe "process_callback" do
        before :each do
          @consumer = mock('Consumer' , :token => 'code')
          options = {:redirect_uri => 'redirect/to/path', :parse=>:query}
          @client.stub!(:oauth_client).and_return(Object.new)
          @client.oauth_client.stub!(:auth_code).and_return(Object.new)
          @client.oauth_client.auth_code.stub!(:get_token).with(@consumer.token, options).and_return(@consumer)
          @token = @authorization.process_callback(@consumer.token, options)
        end
        it 'should return the access_token' do
          @token.should == @consumer.token
        end
        it 'should set the consumer' do
          @client.auth.should == @consumer
        end
      end
    end
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fbgraph-1.9.0 specs/lib/fbauth/authorization_spec.rb
fbgraph-1.8.4 specs/lib/fbauth/authorization_spec.rb
fbgraph-1.8.3 specs/lib/fbauth/authorization_spec.rb