Sha256: 9dd55f7da1f1ff0b8f1f8d0d7396e8d6c576f88700c5bd5b31c2d97911fcf268
Contents?: true
Size: 1.83 KB
Versions: 4
Compression:
Stored size: 1.83 KB
Contents
require 'helper' describe Mutaconf::DSL do let(:target){ {} } let(:dsl){ Mutaconf::DSL.new options } let(:options){ { target: target } } it "should configure properties with instance evaluation" do result = dsl.configure do a 'b' c 'd' end expected = { a: 'b', c: 'd' } result.should be(target) target.should == expected end it "should configure properties with a configuration object" do result = dsl.configure do |config| config.e = 'f' config.g = 'h' config.i = 'j' end expected = { e: 'f', g: 'h', i: 'j' } result.should be(target) target.should == expected end context "with restricted keys" do let(:options){ { target: target, keys: [ :a ] } } it "should raise a key error for a unknown key with instance evaluation" do lambda{ dsl.configure{ b 'c' } }.should raise_error(Mutaconf::KeyError, /'b'/) end it "should raise a key error for an unknown key with a configuration object" do lambda{ dsl.configure{ |config| config.b = 'c' } }.should raise_error(Mutaconf::KeyError, /'b'/) end end context "with restricted keys in lenient mode" do let(:options){ { target: target, keys: [ :a, :e ], lenient: true } } it "should configure restricted properties with instance evaluation" do result = dsl.configure do a 'b' c 'd' e 'f' g 'h' end expected = { a: 'b', e: 'f' } result.should be(target) target.should == expected end it "should configure restricted properties with a configuration object" do result = dsl.configure do |config| config.a = 'b' config.c = 'd' config.e = 'f' config.g = 'h' end expected = { a: 'b', e: 'f' } result.should be(target) target.should == expected end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
mutaconf-0.0.7 | spec/block_spec.rb |
mutaconf-0.0.6 | spec/block_spec.rb |
mutaconf-0.0.5 | spec/block_spec.rb |
mutaconf-0.0.4 | spec/block_spec.rb |