Sha256: a8ee5427fe5d34ec588d47f9849f9378e27125e2295a8f56d99f0e8877b4a9db

Contents?: true

Size: 1.95 KB

Versions: 30

Compression:

Stored size: 1.95 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',
        :daily_active_users => '10'
      }
      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'
      app.daily_active_users.should == 10
    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

30 entries across 30 versions & 1 rubygems

Version Path
fb_graph-2.4.11 spec/fb_graph/application_spec.rb
fb_graph-2.4.10 spec/fb_graph/application_spec.rb
fb_graph-2.4.9 spec/fb_graph/application_spec.rb
fb_graph-2.4.8 spec/fb_graph/application_spec.rb
fb_graph-2.4.7 spec/fb_graph/application_spec.rb
fb_graph-2.4.6 spec/fb_graph/application_spec.rb
fb_graph-2.4.4 spec/fb_graph/application_spec.rb
fb_graph-2.4.3 spec/fb_graph/application_spec.rb
fb_graph-2.4.2 spec/fb_graph/application_spec.rb
fb_graph-2.4.1 spec/fb_graph/application_spec.rb
fb_graph-2.4.0 spec/fb_graph/application_spec.rb
fb_graph-2.3.2 spec/fb_graph/application_spec.rb
fb_graph-2.3.1 spec/fb_graph/application_spec.rb
fb_graph-2.3.0 spec/fb_graph/application_spec.rb
fb_graph-2.2.6 spec/fb_graph/application_spec.rb
fb_graph-2.2.5 spec/fb_graph/application_spec.rb
fb_graph-2.2.4 spec/fb_graph/application_spec.rb
fb_graph-2.2.3 spec/fb_graph/application_spec.rb
fb_graph-2.2.2 spec/fb_graph/application_spec.rb
fb_graph-2.2.1 spec/fb_graph/application_spec.rb