Sha256: 082308f8543c4b26eb541b8a0f1d0460dcec15aa7808966cac3101f7429a4935

Contents?: true

Size: 1.5 KB

Versions: 2

Compression:

Stored size: 1.5 KB

Contents

require 'spec_helper'

describe Tumblr::Client do

  context 'when using the generic copy' do

    before do
      @key = 'thekey'
      Tumblr.configure do |c|
        c.consumer_key = @key
      end
    end

    it 'should give new clients those credentials' do
      client = Tumblr::Client.new
      expect(client.credentials[:consumer_key]).to eq(@key)
    end

    it 'should have it\'s own credentials' do
      expect(Tumblr.credentials[:consumer_key]).to eq(@key)
    end

    it 'should be able to make a new client (using these credentials)' do
      expect(Tumblr.new).to be_a(Tumblr::Client)
      expect(Tumblr.new.credentials[:consumer_key]).to eq(@key)
    end

  end

  context 'when using custom copies of the client' do

    before do
      @client1 = Tumblr::Client.new(:consumer_key => 'key1')
      @client2 = Tumblr::Client.new(:consumer_key => 'key2')
    end

    it 'should keep them separate' do
      expect([
        @client1.credentials[:consumer_key],
        @client2.credentials[:consumer_key]
      ].uniq.count).to eq(2)
    end

  end

  describe :api_scheme do

    it 'defaults to https' do
      expect(Tumblr::Client.new.api_scheme).to eq('https')
    end

    it 'can be set by the initializer' do
      client = Tumblr::Client.new(:api_scheme => 'http')
      expect(client.api_scheme).to eq('http')
    end

    it 'can be set globally' do
      Tumblr.configure do |c|
        c.api_scheme = 'http'
      end
      expect(Tumblr::Client.new.api_scheme).to eq('http')
    end

  end

end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
doomy_client-0.8.5 spec/examples/client_spec.rb
tumblr_client-0.8.5 spec/examples/client_spec.rb