Sha256: 16082ebbacf0fb7541e90f2d6d93a969621f8bae2003ccd84093551624f13cc7

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

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
      allow(api).to receive(:request).with(:post, anything, anything).and_return({ provider_consumer_key: 'test_key' })
    end

    it "posts to the api" do
      expect(api).to 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
      expect(api).to 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

4 entries across 4 versions & 1 rubygems

Version Path
contextio-1.7.2 spec/unit/contextio/oauth_provider_collection_spec.rb
contextio-1.7.1 spec/unit/contextio/oauth_provider_collection_spec.rb
contextio-1.7.0 spec/unit/contextio/oauth_provider_collection_spec.rb
contextio-1.6.0 spec/unit/contextio/oauth_provider_collection_spec.rb