Sha256: 358e33a62412d2e27740e00b1731be7f47d12ee5f8f9c6c7e43b78f4efe74861

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

require 'helper'

describe OpenAmplify::Client do

  before do
    @keys = OpenAmplify::Configuration::VALID_CONFIG_KEYS
  end

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

    after do
      OpenAmplify.reset
    end

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

    describe 'with class configuration' do
      before do
        @config = {
          :api_key       => 'ak',
          :analysis      => 'an',
          :output_format => 'of',
          :scoring       => 'sc',
          :endpoint      => 'ep',
          :user_agent    => 'ua',
          :method        => 'hm',
          :adapter       => 'ha',
        }
      end

      it 'should override module configuration' do
        api = OpenAmplify::Client.new(@config)

        @keys.each do |key|
          api.send(key).must_equal @config[key]
        end
      end

      it 'should override module configuration after' do
        api = OpenAmplify::Client.new

        @config.each do |key, value|
          api.send("#{key}=", value)
        end

        @keys.each do |key|
          api.send("#{key}").must_equal @config[key]
        end
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
openamplify-0.3.0 test/openamplify/client_test.rb