Sha256: 0608b822ffaf4f6a2585a3503cc1304708d183a9325c146167a0cce0c403002d
Contents?: true
Size: 1.93 KB
Versions: 5
Compression:
Stored size: 1.93 KB
Contents
require 'test/unit' require 'app_config' class AppConfigTest < Test::Unit::TestCase def test_missing_files assert_raise(Errno::ENOENT){ ApplicationConfiguration.new('not_here1', 'not_here2') } end def test_empty_files config = ApplicationConfiguration.new('test/empty1.yml', 'test/empty2.yml') assert_equal OpenStruct.new, config.instance_variable_get("@config") end def test_common config = ApplicationConfiguration.new('test/app_config.yml') assert_equal 1, config.size assert_equal 'google.com', config.server end def test_override config = ApplicationConfiguration.new('test/app_config.yml', 'test/development.yml') assert_equal 2, config.size assert_equal 'google.com', config.server end def test_nested config = ApplicationConfiguration.new('test/development.yml') assert_equal 3, config.section.size end def test_array config = ApplicationConfiguration.new('test/development.yml') assert_equal 'yahoo.com', config.section.servers[0].name assert_equal 'amazon.com', config.section.servers[1].name end def test_erb config = ApplicationConfiguration.new('test/development.yml') assert_equal 6, config.computed end def test_recursive_merge config = ApplicationConfiguration.new('test/app_config.yml', 'test/development.yml') assert_equal 'support@domain.com', config.emails.support assert_equal 'webmaster@domain.com', config.emails.webmaster assert_equal 'feedback@domain.com', config.emails.feedback end def test_exception_on_non_existant_values config = ApplicationConfiguration.new('test/app_config.yml') assert_raise(NoMethodError){ config.not_here1 = "blah" } assert_raise(NoMethodError){ config.not_here2 } end def test_reload config = ApplicationConfiguration.new('test/app_config.yml') config.size = 2 assert_equal 2, config.size config.reload! assert_equal 1, config.size end end
Version data entries
5 entries across 5 versions & 2 rubygems