unicorn.git  about / heads / tags
Rack HTTP server for Unix and fast clients
blob 8de0b137ae55718f749dad8b187c36d5bd25771a 1303 bytes (raw)
$ git show v0.1.0:test/unit/test_configurator.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
 
require 'test/unit'
require 'tempfile'
require 'unicorn/configurator'

class TestConfigurator < Test::Unit::TestCase

  def test_config_defaults
    assert_nothing_raised { Unicorn::Configurator.new {} }
  end

  def test_config_invalid
    tmp = Tempfile.new('unicorn_config')
    tmp.syswrite(%q(asdfasdf "hello-world"))
    assert_raises(NoMethodError) do
      Unicorn::Configurator.new(:config_file => tmp.path)
    end
  end

  def test_config_non_existent
    tmp = Tempfile.new('unicorn_config')
    path = tmp.path
    tmp.close!
    assert_raises(Errno::ENOENT) do
      Unicorn::Configurator.new(:config_file => path)
    end
  end

  def test_config_defaults
    cfg = Unicorn::Configurator.new(:use_defaults => true)
    assert_nothing_raised { cfg.commit!(self) }
    Unicorn::Configurator::DEFAULTS.each do |key,value|
      assert_equal value, instance_variable_get("@#{key.to_s}")
    end
  end

  def test_config_defaults_skip
    cfg = Unicorn::Configurator.new(:use_defaults => true)
    skip = [ :logger ]
    assert_nothing_raised { cfg.commit!(self, :skip => skip) }
    @logger = nil
    Unicorn::Configurator::DEFAULTS.each do |key,value|
      next if skip.include?(key)
      assert_equal value, instance_variable_get("@#{key.to_s}")
    end
    assert_nil @logger
  end

end

git clone https://yhbt.net/unicorn.git