summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-09-07 13:38:16 -0700
committerGitHub <noreply@github.com>2016-09-07 13:38:16 -0700
commitdb6a8fd1e7ece631ddcf2f63e2002fc1b028f6e5 (patch)
treecd07aca672c205fd46221727cc73ac90b2223e17
parent484eaa4e585c8b41e829ab51c1c32438ef25da1e (diff)
parente2fbc591cbbd73624ee0ec351b2211b442bd10f8 (diff)
downloadmixlib-config-db6a8fd1e7ece631ddcf2f63e2002fc1b028f6e5.tar.gz
Merge pull request #44 from chef/lcg/add-spec-test
add spec test for unusual behavior
-rw-r--r--spec/mixlib/config_spec.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/mixlib/config_spec.rb b/spec/mixlib/config_spec.rb
index 400d367..daaf5b4 100644
--- a/spec/mixlib/config_spec.rb
+++ b/spec/mixlib/config_spec.rb
@@ -796,6 +796,20 @@ describe Mixlib::Config do
expect(@klass.blah.x).to eql(10)
expect(@klass.save).to eql({ :blah => { :x => 10 } })
end
+
+ # this tests existing (somewhat bizzare) behavior of mixlib-config where testing to
+ # see if a key exists is equivalent to testing if the key has been set -- we can still
+ # retrieve the default value if it was set. the code in chef/chef which merges
+ # knife config values into cli values will be sensitive to this behavior.
+ it "defaults values do not show up when querying with #has_key?" do
+ expect(@klass.blah.has_key?(:x)).to be false
+ expect(@klass.blah.x).to be 5
+ end
+
+ it "if we assign the values, they show up when querying with #has_key?" do
+ @klass.blah.x = 5
+ expect(@klass.blah.has_key?(:x)).to be true
+ end
end
describe "When a configurable exists with a nested context" do