Class ConfigFileTest
In: lib/config_file.rb
Parent: Test::Unit::TestCase

Methods

Public Instance methods

[Source]

# File lib/config_file.rb, line 69
  def setup
    @verbose = $VERBOSE
    $VERBOSE = false
  end

[Source]

# File lib/config_file.rb, line 74
  def teardown
    $VERBOSE = @verbose
  end

[Source]

# File lib/config_file.rb, line 78
  def test_config_file
    tmp_file = nil
    Tempfile.open('config_file') do |f|
      f.puts '---'
      f.puts 'key1: val1'
      f.puts 'key2: val2'
      tmp_file = f
    end
    raise 'no temp file' if tmp_file.nil?
    default_config = { 'key1' => 'def1', 'key2' => 'def2' }
    config_file = ConfigFile.new('/toto', default_config)
    assert_equal(default_config, config_file.__getobj__)
    assert_raises(NoMethodError) { config_file.__setobj__(nil) }
    config_file = ConfigFile.new(tmp_file.path, default_config)
    assert_equal({ 'key1' => 'val1', 'key2' => 'val2' },
                 config_file.__getobj__)
    assert(config_file.__getobj__.frozen?)
  end

[Validate]