spec/mixlib/config_spec.rb in mixlib-config-2.2.3 vs spec/mixlib/config_spec.rb in mixlib-config-2.2.4
- old
+ new
@@ -752,10 +752,28 @@
expect(@klass.blah.x).to eql(5)
expect(@klass.blah.y).to be_nil
expect(@klass.blah.z).to eql(10)
end
+ it "setting the context values in a block overrides the default values" do
+ @klass.blah do
+ x 10
+ y 20
+ end
+ @klass.blah.x.should == 10
+ @klass.blah.y.should == 20
+ end
+
+ it "setting the context values in a yielded block overrides the default values" do
+ @klass.blah do |b|
+ b.x = 10
+ b.y = 20
+ end
+ @klass.blah.x.should == 10
+ @klass.blah.y.should == 20
+ end
+
it "after reset of the parent class, children are reset" do
@klass.blah.x = 10
expect(@klass.blah.x).to eql(10)
@klass.reset
expect(@klass.blah.x).to eql(5)
@@ -848,14 +866,22 @@
@klass.restore( :blah => { :yarr => { :x => 10 } } )
expect(@klass.blah.yarr.x).to eql(10)
expect(@klass.blah.yarr.y).to eql(6)
end
- it "resmoves added properties not included in saved state" do
+ it "removes added properties not included in saved state" do
@klass.blah.yarr.z = 12
@klass.restore( :blah => { :yarr => { :x => 10 } } )
expect(@klass.blah.yarr.x).to eql(10)
expect(@klass.blah.yarr.z).to eql(nil)
+ end
+
+ it "can set a config context from another context" do
+ @klass.blah.blyme = { :x => 7 }
+ blyme = @klass.blah.blyme
+ @klass.blah.yarr.x = 12
+ @klass.blah.yarr = blyme
+ expect(@klass.blah.yarr.x).to eql(7)
end
end
describe "When a config_context with no defaulted values exists" do
before :each do