diff options
author | Claire McQuin <claire@getchef.com> | 2015-10-02 15:14:29 -0700 |
---|---|---|
committer | Claire McQuin <claire@getchef.com> | 2015-10-05 10:00:07 -0700 |
commit | e413ea35bba2ad36453b3d428c343ab3f0bce23a (patch) | |
tree | 2114f4b54a99337f67e66b46f7f172d49c6a5313 /spec/unit/resource | |
parent | 69cf21c8b35d7fb94775db377e810908e5fad54a (diff) | |
download | chef-e413ea35bba2ad36453b3d428c343ab3f0bce23a.tar.gz |
Raise error when running 32-bit scripts on Windows Nano.mcquin/nano/disable-32-bit
Diffstat (limited to 'spec/unit/resource')
-rw-r--r-- | spec/unit/resource/powershell_script_spec.rb | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/spec/unit/resource/powershell_script_spec.rb b/spec/unit/resource/powershell_script_spec.rb index 2505c4a3d7..42fcd61a58 100644 --- a/spec/unit/resource/powershell_script_spec.rb +++ b/spec/unit/resource/powershell_script_spec.rb @@ -30,24 +30,28 @@ describe Chef::Resource::PowershellScript do run_context = Chef::RunContext.new(node, nil, nil) @resource = Chef::Resource::PowershellScript.new("powershell_unit_test", run_context) - end - it "should create a new Chef::Resource::PowershellScript" do + it "creates a new Chef::Resource::PowershellScript" do expect(@resource).to be_a_kind_of(Chef::Resource::PowershellScript) end - it "should set convert_boolean_return to false by default" do + it "sets convert_boolean_return to false by default" do expect(@resource.convert_boolean_return).to eq(false) end - it "should return the value for convert_boolean_return that was set" do + it "returns the value for convert_boolean_return that was set" do @resource.convert_boolean_return true expect(@resource.convert_boolean_return).to eq(true) @resource.convert_boolean_return false expect(@resource.convert_boolean_return).to eq(false) end + it "raises an error when architecture is i386 on Windows Nano Server" do + allow(Chef::Platform).to receive(:windows_nano_server?).and_return(true) + expect{@resource.architecture(:i386)}.to raise_error(Chef::Exceptions::Win32ArchitectureIncorrect, "cannot execute script with requested architecture 'i386' on Windows Nano Server") + end + context "when using guards" do let(:resource) { @resource } before(:each) do @@ -62,32 +66,32 @@ describe Chef::Resource::PowershellScript do expect(inherited_difference).to eq([]) end - it "should allow guard interpreter to be set to Chef::Resource::Script" do + it "allows guard interpreter to be set to Chef::Resource::Script" do resource.guard_interpreter(:script) allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:evaluate_action).and_return(false) resource.only_if("echo hi") end - it "should allow guard interpreter to be set to Chef::Resource::Bash derived from Chef::Resource::Script" do + it "allows guard interpreter to be set to Chef::Resource::Bash derived from Chef::Resource::Script" do resource.guard_interpreter(:bash) allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:evaluate_action).and_return(false) resource.only_if("echo hi") end - it "should allow guard interpreter to be set to Chef::Resource::PowershellScript derived indirectly from Chef::Resource::Script" do + it "allows guard interpreter to be set to Chef::Resource::PowershellScript derived indirectly from Chef::Resource::Script" do resource.guard_interpreter(:powershell_script) allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:evaluate_action).and_return(false) resource.only_if("echo hi") end - it "should enable convert_boolean_return by default for guards in the context of powershell_script when no guard params are specified" do + it "enables convert_boolean_return by default for guards in the context of powershell_script when no guard params are specified" do allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:evaluate_action).and_return(true) allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with( {:convert_boolean_return => true, :code => "$true"}).and_return(Proc.new {}) resource.only_if("$true") end - it "should enable convert_boolean_return by default for guards in non-Chef::Resource::Script derived resources when no guard params are specified" do + it "enables convert_boolean_return by default for guards in non-Chef::Resource::Script derived resources when no guard params are specified" do node = Chef::Node.new run_context = Chef::RunContext.new(node, nil, nil) file_resource = Chef::Resource::File.new('idontexist', run_context) @@ -98,21 +102,21 @@ describe Chef::Resource::PowershellScript do resource.only_if("$true") end - it "should enable convert_boolean_return by default for guards in the context of powershell_script when guard params are specified" do + it "enables convert_boolean_return by default for guards in the context of powershell_script when guard params are specified" do guard_parameters = {:cwd => '/etc/chef', :architecture => :x86_64} allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with( {:convert_boolean_return => true, :code => "$true"}.merge(guard_parameters)).and_return(Proc.new {}) resource.only_if("$true", guard_parameters) end - it "should pass convert_boolean_return as true if it was specified as true in a guard parameter" do + it "passes convert_boolean_return as true if it was specified as true in a guard parameter" do guard_parameters = {:cwd => '/etc/chef', :convert_boolean_return => true, :architecture => :x86_64} allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with( {:convert_boolean_return => true, :code => "$true"}.merge(guard_parameters)).and_return(Proc.new {}) resource.only_if("$true", guard_parameters) end - it "should pass convert_boolean_return as false if it was specified as true in a guard parameter" do + it "passes convert_boolean_return as false if it was specified as true in a guard parameter" do other_guard_parameters = {:cwd => '/etc/chef', :architecture => :x86_64} parameters_with_boolean_disabled = other_guard_parameters.merge({:convert_boolean_return => false, :code => "$true"}) allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with( @@ -127,6 +131,6 @@ describe Chef::Resource::PowershellScript do let(:resource_name) { :powershell_script } let(:interpreter_file_name) { 'powershell.exe' } - it_should_behave_like "a Windows script resource" + it_behaves_like "a Windows script resource" end end |