Sha256: 8c91875d9b70755329b31775e4caec9dc9bc3b2fe87fd470082672cda9f13190

Contents?: true

Size: 1.77 KB

Versions: 9

Compression:

Stored size: 1.77 KB

Contents

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

module Loquor
  class ConfigurationTest < Minitest::Test

    def setup
      Loquor.send(:loquor).instance_variable_set("@config", Configuration.new)
    end

    def test_obtaining_singletion
      refute Loquor.config.nil?
    end

    def test_block_syntax
      test_key = "foobar-123-access"
      Loquor.config do |config|
        config.access_id = test_key
      end
      assert_equal test_key, Loquor.config.access_id
    end

    def test_access_id
      access_id = "test-access-key"
      Loquor.config.access_id = access_id
      assert_equal access_id, Loquor.config.access_id
    end

    def test_secret_key
      secret_key = "test-secret-key"
      Loquor.config.secret_key = secret_key
      assert_equal secret_key, Loquor.config.secret_key
    end

    def test_endpoint
      endpoint = "http://localhost:3000"
      Loquor.config.endpoint = endpoint
      assert_equal endpoint, Loquor.config.endpoint
    end

    def test_substitute_values
      substitute_values = {foo: 'bar'}
      Loquor.config.substitute_values = substitute_values
      assert_equal substitute_values, Loquor.config.substitute_values
    end

    def test_substitute_values_writable
      Loquor.config.substitute_values[:foo] = "bar"
      assert_equal "bar", Loquor.config.substitute_values[:foo]
    end

    def test_missing_access_id_throws_exception
      assert_raises(LoquorConfigurationError) do
        Loquor.config.access_id
      end
    end

    def test_missing_secret_key_throws_exception
      assert_raises(LoquorConfigurationError) do
        Loquor.config.secret_key
      end
    end

    def test_missing_endpoint_throws_exception
      assert_raises(LoquorConfigurationError) do
        Loquor.config.endpoint
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
loquor-1.4.0 test/configuration_test.rb
loquor-1.3.0 test/configuration_test.rb
loquor-1.2.1 test/configuration_test.rb
loquor-1.2.0 test/configuration_test.rb
loquor-1.1.1 test/configuration_test.rb
loquor-1.1.0 test/configuration_test.rb
loquor-1.0.0 test/configuration_test.rb
loquor-0.9.0 test/configuration_test.rb
loquor-0.8.0 test/configuration_test.rb