Sha256: 1aa945f5f91118c5a67d311f667b32adee53525cf130b1041aeb6f8ce490f753

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

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

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

  context "with module configuration" do

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

    after do
      Sambatech.reset
    end

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

    context "with class configuration" do

      before do
        @configuration = {
          :key => 'AT',
          :adapter => :typhoeus,
          :endpoint => 'http://tumblr.com/',
          :proxy => 'http://shayne:sekret@proxy.example.com:8080',
          :user_agent => 'Custom User Agent',
        }
      end

      context "during initialization"

        it "should override module configuration" do
          api = Sambatech::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 = Sambatech::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

1 entries across 1 versions & 1 rubygems

Version Path
sambatech-0.0.1 spec/sambatech/api_spec.rb