Browse files

+ documentation, explicit test cases for certain edge cases

  • Loading branch information...
1 parent 04e760e commit 80327fe5448a5b9d42aad54fc58b2f9bcc6f812b @floere floere committed Jun 28, 2012
View
8 lib/bocuse/configuration.rb
@@ -26,11 +26,13 @@ def merge! other
store.merge! other.store
end
- # Explicit accessor.
+ # Explicit accessor for POROs.
+ #
+ # Note: Unwraps Values.
#
def [] key
- value = @store[key] || Value.new
- value.to_h # TODO This is not ok.
+ value = @store[key]
+ value.to_h rescue value
end
def __resolve__
View
7 spec/files/complex/config/nodes/staging/complex.rb
@@ -21,7 +21,12 @@
# Example: Configuration is accessible.
#
- cfg.cache address: cfg[:server][:internal_ip]
+ # cfg.cache address: cfg[:server][:internal_ip]
+ #
+ # Replace with the above:
+ cfg.cache do
+ address cfg[:server][:internal_ip]
+ end
# Example: Block for later execution?
#
View
9 spec/unit/lib/bocuse/configuration_spec.rb
@@ -7,7 +7,7 @@
let(:configuration) { described_class.new }
describe 'nil values' do
- # TODO Should they be ignored?
+ # TODO Should nil values be ignored when putting together the output?
#
it 'will not be ignored (yet)' do
something = configuration.something
@@ -78,6 +78,13 @@
configuration[:something].should == { :key => 'value' }
end
+ it 'is not modifiable in place as it is a PORO' do
+ something = configuration[:something]
+
+ expect { something << "hello" }.to raise_error
+
+ # configuration.to_h.should == { :something => ["hello"] }
+ end
end
describe 'merge!' do

0 comments on commit 80327fe

Please sign in to comment.