Sha256: d812121b0b452c7d65dc94177242f75f0a02fab9d4e709fa286523a4afa47049

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

require File.join(File.dirname(__FILE__), 'test_helper')

class HirbTest < Test::Unit::TestCase
  before(:all) { Hirb.config_files = nil }
  before(:each) { Hirb.config = nil }

  test "config converts yaml when config file exists" do
    yaml_data = {:blah=>'blah'}
    File.stubs('exists?').returns(true)
    Hirb.config_files = ['ok']
    YAML::expects(:load_file).returns(yaml_data)
    Hirb.config.should == yaml_data
  end
  
  test "config defaults to hash when no config file" do
    File.stubs('exists?').returns(false)
    Hirb.config.should == {}
  end
  
  test "config reloads if given explicit reload" do
    Hirb.config
    Hirb.expects(:read_config_file).returns({})
    Hirb.config(true)
  end

  test "config reads multiple config files and merges them" do
    Hirb.config_files = %w{one two}
    Hirb.expects(:read_config_file).times(2).returns({:output=>{"String"=>:auto_table}}, {:output=>{"Array"=>:auto_table}})
    Hirb.config.should == {:output=>{"Array"=>:auto_table, "String"=>:auto_table}}
    Hirb.config_files = nil
  end

  test "config_file sets correctly when no ENV['HOME']" do
    Hirb.config_files = nil
    home = ENV.delete('HOME')
    Hirb.config_files[0].class.should == String
    ENV["HOME"] = home
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hirb-0.3.1 test/hirb_test.rb
hirb-0.3.0 test/hirb_test.rb
hirb-0.2.10 test/hirb_test.rb