Sha256: 510e4c78c4d21fffa92b1456bb31be14120f177fda70f93c5c92b34900986a0b

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

require 'rest-core/test'

describe RestCore::Facebook do
  before do
    @rg  = RestCore::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 == '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 == result
    @rg.data.should == result
  end

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

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rest-core-0.3.0.pre.2 test/client/facebook/test_oauth.rb
rest-core-0.3.0.pre.1 test/client/facebook/test_oauth.rb
rest-core-0.3.0.pre.0 test/client/facebook/test_oauth.rb