summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan McLellan <btm@getchef.com>2014-09-03 14:35:54 -0700
committerBryan McLellan <btm@getchef.com>2014-09-03 14:35:54 -0700
commit2444d1ed86b2d3ba88e626a54f045f64b0cd51de (patch)
tree98a8bbacc6887e308a4c39b3bfa3a5a45fa86d2f
parent3166bd959316c6fdb54455607332bf80e8eed147 (diff)
downloadchef-2444d1ed86b2d3ba88e626a54f045f64b0cd51de.tar.gz
Make Chef::Util::Powershell::Cmdlet Ruby 1.8.7 friendly
Use 1.8 hash syntax Explicitly convert the symbol to a string for comparison
-rw-r--r--lib/chef/util/powershell/cmdlet.rb2
-rw-r--r--spec/unit/util/powershell/cmdlet_spec.rb12
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/chef/util/powershell/cmdlet.rb b/lib/chef/util/powershell/cmdlet.rb
index 40edbb13c6..ddca732b40 100644
--- a/lib/chef/util/powershell/cmdlet.rb
+++ b/lib/chef/util/powershell/cmdlet.rb
@@ -88,7 +88,7 @@ class Chef::Util::Powershell
include Chef::Mixin::WindowsArchitectureHelper
def validate_switch_name!(switch_parameter_name)
- if !!(switch_parameter_name =~ /\A[A-Za-z]+[_a-zA-Z0-9]*\Z/) == false
+ if !!(switch_parameter_name.to_s =~ /\A[A-Za-z]+[_a-zA-Z0-9]*\Z/) == false
raise ArgumentError, "`#{switch_parameter_name}` is not a valid PowerShell cmdlet switch parameter name"
end
end
diff --git a/spec/unit/util/powershell/cmdlet_spec.rb b/spec/unit/util/powershell/cmdlet_spec.rb
index a964f607c8..39b3585c17 100644
--- a/spec/unit/util/powershell/cmdlet_spec.rb
+++ b/spec/unit/util/powershell/cmdlet_spec.rb
@@ -80,27 +80,27 @@ describe Chef::Util::Powershell::Cmdlet do
end
it 'ignores switches with a false value' do
- @cmdlet.send(:command_switches_string, {foo: false}).should eql('')
+ @cmdlet.send(:command_switches_string, {:foo => false}).should eql('')
end
it 'should correctly handle a value type of string' do
- @cmdlet.send(:command_switches_string, {foo: 'bar'}).should eql("-foo 'bar'")
+ @cmdlet.send(:command_switches_string, {:foo => 'bar'}).should eql("-foo 'bar'")
end
it 'should correctly handle a value type of string even when it is 0 length' do
- @cmdlet.send(:command_switches_string, {foo: ''}).should eql("-foo ''")
+ @cmdlet.send(:command_switches_string, {:foo => ''}).should eql("-foo ''")
end
it 'should not quote integers' do
- @cmdlet.send(:command_switches_string, {foo: 1}).should eql("-foo 1")
+ @cmdlet.send(:command_switches_string, {:foo => 1}).should eql("-foo 1")
end
it 'should not quote floats' do
- @cmdlet.send(:command_switches_string, {foo: 1.0}).should eql("-foo 1.0")
+ @cmdlet.send(:command_switches_string, {:foo => 1.0}).should eql("-foo 1.0")
end
it 'has just the switch when the value is true' do
- @cmdlet.send(:command_switches_string, {foo: true}).should eql("-foo")
+ @cmdlet.send(:command_switches_string, {:foo => true}).should eql("-foo")
end
end
end