Sha256: 7a46417d694d4fb6d481f831897a1dc35a11134093d809683340c063d484ea87

Contents?: true

Size: 1018 Bytes

Versions: 11

Compression:

Stored size: 1018 Bytes

Contents

require 'spec_helper'
require 'contextio/oauth_provider_collection'

describe ContextIO::OAuthProviderCollection do
  let(:api) { double('API', url_for: 'url from api') }

  subject { ContextIO::OAuthProviderCollection.new(api) }

  describe "#create" do
    before do
      api.stub(:request).with(:post, anything, anything).and_return({ provider_consumer_key: 'test_key' })
    end

    it "posts to the api" do
      api.should_receive(:request).with(
        :post,
        'url from api',
        type: 'GMAIL',
        provider_consumer_key: 'test_key',
        provider_consumer_secret: 'test_secret'
      )

      subject.create('GMAIL', 'test_key', 'test_secret')
    end

    it "doesn't make any more API requests than it needs to" do
      api.should_receive(:request).exactly(:once)

      subject.create('GMAIL', 'test_key', 'test_secret')
    end

    it "returns an OAuthProvider" do
      expect(subject.create('GMAIL', 'test_key', 'test_secret')).to be_a(ContextIO::OAuthProvider)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
contextio-1.5.0 spec/unit/contextio/oauth_provider_collection_spec.rb
contextio-1.4.0 spec/unit/contextio/oauth_provider_collection_spec.rb
contextio-1.3.0 spec/unit/contextio/oauth_provider_collection_spec.rb
contextio-1.2.4 spec/unit/contextio/oauth_provider_collection_spec.rb
contextio-1.2.3 spec/contextio/oauth_provider_collection_spec.rb
contextio-1.2.2 spec/contextio/oauth_provider_collection_spec.rb
contextio-1.2.1 spec/contextio/oauth_provider_collection_spec.rb
contextio-1.2.0 spec/contextio/oauth_provider_collection_spec.rb
contextio-1.1.0 spec/contextio/oauth_provider_collection_spec.rb
contextio-1.0.1 spec/contextio/oauth_provider_collection_spec.rb
contextio-1.0.0 spec/contextio/oauth_provider_collection_spec.rb