Sha256: 79d087dd317de57482afe9cfd2bb3bc7e38ad07ea66144b5fe561c917c9da3b2

Contents?: true

Size: 1.61 KB

Versions: 2

Compression:

Stored size: 1.61 KB

Contents

require File.expand_path('../../spec_helper', __FILE__)

describe Thounds::API do
  before do
    @keys = Thounds::Configuration::VALID_OPTIONS_KEYS
  end

  context "with module configuration" do

    before do
      Thounds.configure do |config|
        @keys.each do |key|
          config.send("#{key}=", key)
        end
      end
    end

    after do
      Thounds.reset
    end

    it "should inherit module configuration" do
      api = Thounds::API.new
      @keys.each do |key|
        api.send(key).should == key
      end
    end

    context "with class configuration" do

      before do
        @configuration = {
          :consumer_key => 'CK',
          :consumer_secret => 'CS',
          :oauth_token => 'OT',
          :oauth_token_secret => 'OS',
          :adapter => :typhoeus,
          :endpoint => 'http://tumblr.com/',
          :format => :xml,
          :proxy => 'http://giovanni:secret@proxy.example.com:8080',
          :user_agent => 'Custom User Agent',
        }
      end

      context "during initialization"

        it "should override module configuration" do
          api = Thounds::API.new(@configuration)
          @keys.each do |key|
            api.send(key).should == @configuration[key]
          end
        end

      context "after initilization" do

        it "should override module configuration after initialization" do
          api = Thounds::API.new
          @configuration.each do |key, value|
            api.send("#{key}=", value)
          end
          @keys.each do |key|
            api.send(key).should == @configuration[key]
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thounds-0.0.2 spec/thounds/api_spec.rb
thounds-0.0.1 spec/thounds/api_spec.rb