Sha256: e35a8c63eb00e2ab0bcb92ab08b836953ca04999b552f377fae1772308c10fe5

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

require 'rest-more/test'

describe RC::Facebook do
  before do
    @rg  = RC::Facebook.new(:app_id => '29', :secret => '18')
    @uri = 'http://zzz.tw'
  end

  after do
    WebMock.reset!
  end

  should 'return correct oauth url' do
    TestHelper.normalize_url(@rg.authorize_url(:redirect_uri => @uri)).
    should.eq 'https://graph.facebook.com/oauth/authorize?' \
              'client_id=29&redirect_uri=http%3A%2F%2Fzzz.tw'
  end

  should 'do authorizing and parse result and save it in data' do
    stub_request(:get, 'https://graph.facebook.com/oauth/access_token?' \
                       'client_id=29&client_secret=18&code=zzz&'        \
                       'redirect_uri=http%3A%2F%2Fzzz.tw').
      to_return(:body => 'access_token=baken&expires=2918')

    result = {'access_token' => 'baken', 'expires' => '2918'}

    @rg.authorize!(:redirect_uri => @uri, :code => 'zzz').
             should.eq result
    @rg.data.should.eq result
  end

  should 'not append access_token in authorize_url even presented' do
    RC::Facebook.new(:access_token => 'do not use me').authorize_url.
      should.eq 'https://graph.facebook.com/oauth/authorize'
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rest-more-0.7.2.1 test/client/facebook/test_oauth.rb
rest-more-0.7.2 test/client/facebook/test_oauth.rb