Sha256: 9d64082ab81fa43efcf9cbf7bd9c214fcd231f2adaad445383aa5d616e306382

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

if respond_to?(:require_relative, true)
  require_relative 'common'
else
  require File.dirname(__FILE__) + '/common'
end

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

  it 'would 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

  it 'would 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

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rest-graph-1.2.0 test/test_oauth.rb
rest-graph-1.1.1 test/test_oauth.rb