spec/config/configurable_spec.rb in deimos-ruby-1.4.0.pre.beta1 vs spec/config/configurable_spec.rb in deimos-ruby-1.4.0.pre.beta2

- old
+ new

@@ -27,9 +27,25 @@ expect(MyConfig.config.listy_objects).to be_empty expect { MyConfig.config.blah }.to raise_error(NameError) expect { MyConfig.config.group.set4 }.to raise_error(NameError) end + it 'should not call the proc until it has to' do + num_calls = 0 + value_proc = proc do + num_calls += 1 + num_calls + end + MyConfig.configure do + setting :set_with_proc, default_proc: value_proc + end + expect(num_calls).to eq(0) + expect(MyConfig.config.set_with_proc).to eq(1) + # calling twice should not call the proc again + expect(MyConfig.config.set_with_proc).to eq(1) + expect(num_calls).to eq(1) + end + it "should raise error when setting configs that don't exist" do expect { MyConfig.configure { set15 'some_value' } }.to raise_error(NameError) end it 'should add values' do