Sha256: 663f3866d8a55eb522b71180967f5d384a5ccc883b90e36b05872bf8d8ea1cd5

Contents?: true

Size: 1.46 KB

Versions: 22

Compression:

Stored size: 1.46 KB

Contents

class TestConfig < Test::Unit::TestCase
  def test_define_param
    assert { !Yao.config.respond_to?(:foobar) }

    Yao.config.param :foobar, nil
    assert { Yao.config.respond_to?(:foobar) }
  end

  def test_raise_undefined_key
    e = nil
    begin
      Yao.config.set :some_imaginary_key, 123
    rescue => e
    end
    assert { e.message == "Undefined config key some_imaginary_key" }
  end

  def test_define_hook
    hooked_value = nil

    Yao.config.param :do_hook, "sample" do |v|
      hooked_value = v
    end
    assert("param definition should not hook callbacks") do
      hooked_value.nil?
    end

    Yao.config.set :do_hook, "true value"
    assert { hooked_value = "true value" }

    Yao.config.do_hook("next value")
    assert { Yao.config.do_hook == "next value" }
    assert { hooked_value == "next value" }
  end

  def test_delayed_hook
    hooked_value = nil
    Yao.config.param :def_hook1, "test" do |v|
      if Yao.config.def_hook2
        hooked_value = v
      end
    end
    Yao.config.param :def_hook2, false

    Yao.configure do
      def_hook1 "test 2"
      def_hook2 true
    end

    assert { hooked_value == "test 2" }
  end

  def test_auth_is_hooked
    auth = Yao::Auth
    count = Yao::Config::HOOK_RENEW_CLIENT_KEYS.size
    mock(auth).try_new.times(count)
    Yao::Config::HOOK_RENEW_CLIENT_KEYS.each do |key|
      Yao.configure do
        set key, "dummy"
      end
    end

    assert_received(auth) {|a| a.try_new.times(count) }
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
yao-0.3.0 test/yao/test_config.rb
yao-0.2.13 test/yao/test_config.rb
yao-0.2.12 test/yao/test_config.rb
yao-0.2.11 test/yao/test_config.rb
yao-0.2.10 test/yao/test_config.rb
yao-0.2.9 test/yao/test_config.rb
yao-0.2.8 test/yao/test_config.rb
yao-0.2.7 test/yao/test_config.rb
yao-0.2.6 test/yao/test_config.rb
yao-0.2.5 test/yao/test_config.rb
yao-0.2.4 test/yao/test_config.rb
yao-0.2.2 test/yao/test_config.rb
yao-0.2.1 test/yao/test_config.rb
yao-0.2.0 test/yao/test_config.rb
yao-0.2.0.rc1 test/yao/test_config.rb
yao-0.1.1 test/yao/test_config.rb
yao-0.1.0 test/yao/test_config.rb
yao-0.0.6 test/yao/test_config.rb
yao-0.0.5 test/yao/test_config.rb
yao-0.0.4 test/yao/test_config.rb