Sha256: 7b19ef3af05043195961fe522be2a0675397b9c827f1e194fcc5a9931951042a

Contents?: true

Size: 1.54 KB

Versions: 13

Compression:

Stored size: 1.54 KB

Contents

require 'helper'

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

  context "with module configuration" do
     before do
      FullContact.configure do |config|
        @keys.each do |key|
          config.send("#{key}=", key)
        end
      end
    end

    after do
      FullContact.reset
    end

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

    context "with class configuration" do

      before do
        @configuration = {
          :api_key => 'api_key',
          :adapter => :typhoeus,
          :endpoint => 'http://tumblr.com/',
          :gateway => 'apigee-1111.apigee.com',
          :format => :xml,
          :proxy => 'http://erik:sekret@proxy.example.com:8080',
          :user_agent => 'Custom User Agent',
        }
      end

      context "during initialization"

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

13 entries across 13 versions & 1 rubygems

Version Path
fullcontact-0.7.0 spec/ruby_fullcontact/api_spec.rb
fullcontact-0.6.1 spec/ruby_fullcontact/api_spec.rb
fullcontact-0.6.0 spec/ruby_fullcontact/api_spec.rb
fullcontact-0.5.0 spec/ruby_fullcontact/api_spec.rb
fullcontact-0.4.4 spec/ruby_fullcontact/api_spec.rb
fullcontact-0.4.1 spec/ruby_fullcontact/api_spec.rb
fullcontact-0.3.3 spec/ruby_fullcontact/api_spec.rb
fullcontact-0.3.2 spec/ruby_fullcontact/api_spec.rb
fullcontact-0.3.1 spec/ruby_fullcontact/api_spec.rb
fullcontact-0.3.0 spec/ruby_fullcontact/api_spec.rb
fullcontact-0.2.0 spec/ruby_fullcontact/api_spec.rb
fullcontact-0.1.4 spec/ruby_fullcontact/api_spec.rb
fullcontact-0.1.3 spec/ruby_fullcontact/api_spec.rb