summaryrefslogtreecommitdiffstats
path: root/spec/unit/parameter.rb
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2009-03-13 23:30:03 +0100
committerJames Turnbull <james@lovedthanlost.net>2009-05-02 09:08:42 +1000
commitd51d87e1f04b643f4efb5c6453a2c1fc9a1ca8e5 (patch)
tree108e00dc3263ed3101e40f034e1c229cb7ccf467 /spec/unit/parameter.rb
parenta1c0ae0fe3c4bef6f21240c4d0a8da985cc7c8af (diff)
downloadpuppet-d51d87e1f04b643f4efb5c6453a2c1fc9a1ca8e5.tar.gz
puppet-d51d87e1f04b643f4efb5c6453a2c1fc9a1ca8e5.tar.xz
puppet-d51d87e1f04b643f4efb5c6453a2c1fc9a1ca8e5.zip
Add an unmunge capability to type parameters and properties
Unmunge is the reverse of munge. While munge allows the type to return a different parameter value or properties should than the one it was created with, unmunge does the reverse. It can be used for instance to store a value in a different representation but still be able to return genuine value to the outside world. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec/unit/parameter.rb')
-rwxr-xr-xspec/unit/parameter.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/unit/parameter.rb b/spec/unit/parameter.rb
index 94f5cfd7b..42d3103bd 100755
--- a/spec/unit/parameter.rb
+++ b/spec/unit/parameter.rb
@@ -46,6 +46,16 @@ describe Puppet::Parameter do
@parameter.value.should == "bar"
end
+ it "should unmunge the value when accessing the actual value" do
+ @parameter.class.unmunge do |value| value.to_sym end
+ @parameter.value = "foo"
+ @parameter.value.should == :foo
+ end
+
+ it "should return the actual value by default when unmunging" do
+ @parameter.unmunge("bar").should == "bar"
+ end
+
it "should return any set value" do
@parameter.value = "foo"
@parameter.value.should == "foo"