Sha256: f8bcb20608d629ca70df7260fb05b660e8f9e3619590e6f5f005a8600b95e554

Contents?: true

Size: 1.88 KB

Versions: 21

Compression:

Stored size: 1.88 KB

Contents

require 'spec_helper'

describe FbGraph::Application do
  let(:app) { FbGraph::Application.new('client_id') }

  describe '.new' do
    it 'should setup all supported attributes' do
      attributes = {
        :id          => '12345',
        :name        => 'FbGraph',
        :description => 'Owsome Facebook Graph Wrapper',
        :category    => 'Programming',
        :link        => 'http://github.com/nov/fb_graph',
        :secret      => 'sec sec'
      }
      app = FbGraph::Application.new(attributes.delete(:id), attributes)
      app.identifier.should  == '12345'
      app.name.should        == 'FbGraph'
      app.description.should == 'Owsome Facebook Graph Wrapper'
      app.category.should    == 'Programming'
      app.link.should        == 'http://github.com/nov/fb_graph'
      app.secret.should      == 'sec sec'
    end
  end

  describe '#get_access_token' do
    before { app.secret = 'secret' }

    it 'should return Rack::OAuth2::AccessToken::Legacy' do
      mock_graph :post, 'oauth/access_token', 'token_response' do
        token = app.get_access_token
        token.should be_instance_of(Rack::OAuth2::AccessToken::Legacy)
        token.access_token.should == 'token'
      end
    end
  end

  describe '#access_token' do
    context 'when access token already exists' do
      before { app.access_token = "token" }
      it 'should not fetch new token' do
        app.should_not_receive(:get_access_token)
        app.access_token
      end
    end

    context 'otherwise' do
      context 'when secret exists' do
        before { app.secret = 'secret' }
        it 'should fetch new token' do
          app.should_receive(:get_access_token)
          app.access_token
        end
      end

      context 'otherwise' do
        it 'should not fetch new token' do
          app.should_not_receive(:get_access_token)
          app.access_token
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
fb_graph-2.1.7 spec/fb_graph/application_spec.rb
fb_graph-2.1.6 spec/fb_graph/application_spec.rb
fb_graph-2.1.5 spec/fb_graph/application_spec.rb
fb_graph-2.1.4 spec/fb_graph/application_spec.rb
fb_graph-2.1.3 spec/fb_graph/application_spec.rb
fb_graph-2.1.2 spec/fb_graph/application_spec.rb
fb_graph-2.1.1 spec/fb_graph/application_spec.rb
fb_graph-2.1.0 spec/fb_graph/application_spec.rb
fb_graph-2.1.0.alpha spec/fb_graph/application_spec.rb
fb_graph-2.0.2 spec/fb_graph/application_spec.rb
fb_graph-2.0.1 spec/fb_graph/application_spec.rb
fb_graph-2.0.0 spec/fb_graph/application_spec.rb
fb_graph-2.0.0.beta spec/fb_graph/application_spec.rb
fb_graph-2.0.0.alpha spec/fb_graph/application_spec.rb
fb_graph-1.9.5 spec/fb_graph/application_spec.rb
fb_graph-1.9.4 spec/fb_graph/application_spec.rb
fb_graph-1.9.3 spec/fb_graph/application_spec.rb
fb_graph-1.9.2 spec/fb_graph/application_spec.rb
fb_graph-1.9.1 spec/fb_graph/application_spec.rb
fb_graph-1.9.0 spec/fb_graph/application_spec.rb