summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2014-08-13 16:45:32 -0700
committerAdam Edwards <adamed@opscode.com>2014-08-29 14:42:43 -0700
commite64a2f512bd5501acf2953493e92336de490bf80 (patch)
tree5c6f6979260de042035aa3b63e02354d41d5ff2c
parent262f174320be0f1cc0e600dc2d2527dbd3b8266a (diff)
downloadchef-e64a2f512bd5501acf2953493e92336de490bf80.tar.gz
Updated powershell functional tests to work with changes to Chef::Util::Powershell:Cmdlet
-rw-r--r--spec/functional/util/powershell/cmdlet_spec.rb32
1 files changed, 15 insertions, 17 deletions
diff --git a/spec/functional/util/powershell/cmdlet_spec.rb b/spec/functional/util/powershell/cmdlet_spec.rb
index 1bc8b81bbc..57a1117b51 100644
--- a/spec/functional/util/powershell/cmdlet_spec.rb
+++ b/spec/functional/util/powershell/cmdlet_spec.rb
@@ -20,31 +20,29 @@ require 'json'
require File.expand_path('../../../../spec_helper', __FILE__)
describe Chef::Util::Powershell::Cmdlet, :windows_only do
+ before(:all) do
+ ohai = Ohai::System.new
+ ohai.load_plugins
+ ohai.run_plugins(true, ['platform', 'kernel'])
+ @node = Chef::Node.new
+ @node.consume_external_attrs(ohai.data, {})
+ end
let(:cmd_output_format) { :text }
- let(:simple_cmdlet) { Chef::Util::Powershell::Cmdlet.new('get-childitem', cmd_output_format, {:depth => 2}) }
- let(:invalid_cmdlet) { Chef::Util::Powershell::Cmdlet.new('get-idontexist', cmd_output_format) }
- let(:cmdlet_get_item_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new('get-item', cmd_output_format, {:depth => 2}) }
- let(:cmdlet_alias_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new('alias', cmd_output_format, {:depth => 2}) }
+ let(:simple_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, 'get-childitem', cmd_output_format, {:depth => 2}) }
+ let(:invalid_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, 'get-idontexist', cmd_output_format) }
+ let(:cmdlet_get_item_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, 'get-item', cmd_output_format, {:depth => 2}) }
+ let(:cmdlet_alias_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, 'alias', cmd_output_format, {:depth => 2}) }
let(:etc_directory) { "#{ENV['systemroot']}\\system32\\drivers\\etc" }
- let(:architecture_cmdlet) { Chef::Util::Powershell::Cmdlet.new("$env:PROCESSOR_ARCHITECTURE")}
+ let(:architecture_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "$env:PROCESSOR_ARCHITECTURE")}
+
it "executes a simple process" do
result = simple_cmdlet.run
expect(result.succeeded?).to eq(true)
end
it "returns a PowershellCmdletException exception if the command cannot be executed" do
- exception_occurred = nil
-
- begin
- invalid_cmdlet.run
- exception_occurred = false
- rescue Chef::Util::Powershell::CmdletException => e
- exception_occurred = true
- expect(e.cmdlet_result.succeeded?).to eq(false)
- end
-
- expect(exception_occurred).to eq(true)
- end
+ expect {invalid_cmdlet.run}.to raise_error(Chef::Exceptions::PowershellCmdletException)
+ end
it "executes a 64-bit command on a 64-bit OS, 32-bit otherwise" do
os_arch = ENV['PROCESSOR_ARCHITEW6432']