summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Mathur <nikita.mathur@chef.io>2022-06-07 14:34:50 +0530
committerNikita Mathur <nikita.mathur@chef.io>2022-06-07 14:34:52 +0530
commit62585a2cfebada08c829234efe585874305c7372 (patch)
tree834c75aa03cfb1418419729e32407cba603c05fd
parentfc32fe0b64b0338f7d7261ed3205f3142b9b8d20 (diff)
downloadmixlib-config-62585a2cfebada08c829234efe585874305c7372.tar.gz
Spec added for nested hash when configurables are presentnm/nested-hash-config
Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
-rw-r--r--spec/mixlib/config_spec.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/mixlib/config_spec.rb b/spec/mixlib/config_spec.rb
index 1155e75..974111e 100644
--- a/spec/mixlib/config_spec.rb
+++ b/spec/mixlib/config_spec.rb
@@ -1298,6 +1298,27 @@ describe Mixlib::Config do
expect(ConfigIt.windows_path).to eql('C:\Windows Has Awful\Paths')
end
end
+ context "when configurable and hash is defined" do
+ before :each do
+ @klass = Class.new
+ @klass.extend(::Mixlib::Config)
+ @klass.class_eval do
+ configurable(:environment) do |c|
+ c.defaults_to({})
+ end
+ end
+ end
+
+ let(:hash) do
+ {
+ environment: { "GEM_PATH" => "SOME_PATH" },
+ }
+ end
+ it "configures the config object from a hash" do
+ hash_config = @klass.from_hash(hash)
+ expect(hash_config[:environment]).to eql({ "GEM_PATH" => "SOME_PATH" })
+ end
+ end
context "when contexts in the hash are undefined and strict disabled" do
before do
ConfigIt.strict_mode = true