From 5291fd70df7b9360b186ff104115f080e949f5e5 Mon Sep 17 00:00:00 2001 From: Steven Murawski Date: Wed, 3 Feb 2016 12:55:56 -0600 Subject: Allow PowerShellTypeCoercions to translate Chef::Node::ImmutableArray --- lib/chef/mixin/powershell_type_coercions.rb | 3 ++- spec/unit/mixin/powershell_type_coercions_spec.rb | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/chef/mixin/powershell_type_coercions.rb b/lib/chef/mixin/powershell_type_coercions.rb index e9fa6b74ac..60c04e85ae 100644 --- a/lib/chef/mixin/powershell_type_coercions.rb +++ b/lib/chef/mixin/powershell_type_coercions.rb @@ -28,8 +28,9 @@ class Chef FalseClass => { :type => lambda { |x| "$false" }}, TrueClass => { :type => lambda { |x| "$true" }}, Hash => {:type => Proc.new { |x| translate_hash(x)}}, - Chef::Node::ImmutableMash => {:type => Proc.new { |x| translate_hash(x)}}, Array => {:type => Proc.new { |x| translate_array(x)}}, + Chef::Node::ImmutableMash => {:type => Proc.new { |x| translate_hash(x)}}, + Chef::Node::ImmutableArray => {:type => Proc.new { |x| translate_array(x)}}, } end diff --git a/spec/unit/mixin/powershell_type_coercions_spec.rb b/spec/unit/mixin/powershell_type_coercions_spec.rb index c1184cce7c..f7b4fcd723 100644 --- a/spec/unit/mixin/powershell_type_coercions_spec.rb +++ b/spec/unit/mixin/powershell_type_coercions_spec.rb @@ -69,6 +69,11 @@ describe Chef::Mixin::PowershellTypeCoercions do expect(test_class.translate_type(test_mash)).to eq("@{a=1;b=1.2;c=$false;d=$true}") end + it "translates a Chef::Node::ImmutableArray like an array" do + test_array = Chef::Node::ImmutableArray.new([true, false]) + expect(test_class.translate_type(test_array)).to eq("@($true,$false)") + end + it "falls back :to_psobject if we have not defined at explicit rule" do ps_obj = double("PSObject") expect(ps_obj).to receive(:to_psobject).and_return("$true") -- cgit v1.2.1