spec/figgy_spec.rb in figgy-0.9.1 vs spec/figgy_spec.rb in figgy-1.0.0

- old
+ new

@@ -110,12 +110,68 @@ config.values[:number] = 3 config.values.number.should == 3 config.values.number = 4 config.values.number.should == 4 end + + it "supports indifferent hash notation on the top-level config object" do + write_config 'values', "number: 1" + config = test_config + config['values'].should == config.values + config[:values].should == config.values + end + + context "performing basic hash operations" do + let(:config) do + write_config 'values', <<-YML + with: + one: 1 + two: 2 + without: + two: 2 + another: + three: 3 + altogether: + one: 1 + two: 2 + three: 3 + YML + test_config + end + + it "can delete a key" do + config.values.with.delete(:one).should == 1 + config.values.with.should == config.values.without + end + + it "can look up values for a list of keys" do + config.values.with.values_at(:one,:two).should == [1,2] + end + + it "can merge with another hash" do + config.values.with.merge(config.values.another).should == config.values.altogether + end + end end + context 'oddities' do + it "returns false for empty files (cf. YAML.load(''))" do + write_config 'empty', '' + test_config.empty.should == false + end + + it "returns false for files containing a literal false" do + write_config 'maybe', 'false' + test_config.maybe.should == false + end + + it "returns nil when explicitly set to that value in the YAML file" do + write_config 'reason_to_do_this', nil.to_yaml + test_config.reason_to_do_this.should == nil + end + end + context "multiple roots" do it "can be told to read from multiple directories" do write_config 'root1/values', 'foo: 1' write_config 'root2/values', 'bar: 2' @@ -341,16 +397,16 @@ end end context "freezing" do it "leaves results unfrozen by default" do - write_config 'values', 'foo: 1' + write_config 'values', "foo: '1'" test_config.values.foo.should_not be_frozen end it "freezes the results when config.freeze = true" do - write_config 'values', 'foo: 1' + write_config 'values', "foo: '1'" config = test_config do |config| config.freeze = true end config.values.should be_frozen end @@ -378,15 +434,7 @@ case obj when Hash then obj.each { |k, v| assert_deeply_frozen(k); assert_deeply_frozen(v) } when Array then obj.each { |v| assert_deeply_frozen(v) } end end - end -end - -describe Figgy do - describe 'CnuConfig drop-in compatibility' do - it "should maybe support path_formatter = some_proc.call(config_name, overlays)" - it "should support preload's all_key_names when using path_formatter" - it "should support preload's all_key_names when using path_formatter" end end