2010-01-22 07:38:23 +00:00
|
|
|
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
|
|
|
|
|
|
|
class ConfigTest < Test::Unit::TestCase
|
|
|
|
context "Hobo configuration" do
|
2010-01-24 07:38:31 +00:00
|
|
|
setup do
|
|
|
|
@settings = {:a => { :b => 1}}
|
2010-01-24 08:09:15 +00:00
|
|
|
Hobo.config!(@settings)
|
2010-01-24 07:38:31 +00:00
|
|
|
end
|
|
|
|
|
2010-01-24 08:09:15 +00:00
|
|
|
should "alter the config given a dot chain of keys" do
|
|
|
|
Hobo.set_config_value 'a.b', 2
|
2010-01-30 06:03:07 +00:00
|
|
|
assert_equal Hobo.config[:a][:b], 2
|
2010-01-24 08:09:15 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
should "prevent the alteration of a non leaf setting value" do
|
|
|
|
assert_raise Hobo::InvalidSettingAlteration do
|
2010-01-30 06:23:33 +00:00
|
|
|
Hobo.set_config_value 'a', 2
|
2010-01-24 08:09:15 +00:00
|
|
|
end
|
|
|
|
end
|
2010-01-30 06:03:07 +00:00
|
|
|
|
|
|
|
should "not alter settings through the chain method when provided and empty string" do
|
|
|
|
prev = Hobo.config
|
|
|
|
Hobo.set_config_value '', 2
|
|
|
|
assert_equal Hobo.config, prev
|
|
|
|
end
|
2010-01-22 07:38:23 +00:00
|
|
|
end
|
|
|
|
end
|