spec/dockly/util/dsl_spec.rb in dockly-util-0.0.8 vs spec/dockly/util/dsl_spec.rb in dockly-util-0.0.9
- old
+ new
@@ -47,10 +47,11 @@
expect { test_instance.chips('bbq') }
.to change { test_instance.instance_variable_get(:@chips) }
.to 'bbq'
end
end
+
end
end
describe '.dsl_class_attribute' do
context 'when the sceond argument is not a DSL' do
@@ -194,9 +195,32 @@
context 'when a value is given' do
it 'adds the pair to the default_values hash' do
test_class.send(:default_value, :chips, 'Cool Ranch')
test_class.default_values[:chips].should == 'Cool Ranch'
+ end
+ end
+
+ context 'when extending' do
+ class Parent
+ include Dockly::Util::DSL
+
+ dsl_attribute :test
+ default_value :test, 'not so fancy'
+ end
+
+ class Child < Parent
+ dsl_attribute :fancy_test
+ default_value :fancy_test, 'fancy'
+ end
+
+ it "should have all default values in child" do
+ expect( Child.default_values).to match_array(
+ [[:fancy_test, 'fancy'], [:test, 'not so fancy']] )
+ end
+
+ it "should not include child default values in parent" do
+ expect( Parent.default_values).to_not include(:fancy_test)
end
end
end
describe '#initialize' do