summaryrefslogtreecommitdiff
path: root/spec/functional/util
diff options
context:
space:
mode:
authorBryan McLellan <btm@loftninjas.org>2014-09-03 14:13:46 -0400
committerJay Mundrawala <jdmundrawala@gmail.com>2014-09-19 12:48:05 -0700
commite3d685d9cce83342f03a624a3fe7121ccc34443a (patch)
treeefac98e5045469c33f219e01a1e89db5278c2321 /spec/functional/util
parenta97bc51649be2ee784843a21bd8484ce61ac589f (diff)
downloadchef-e3d685d9cce83342f03a624a3fe7121ccc34443a.tar.gz
Switch fileformat to unix, clean up whitespace.
Converts a few files from CRLF->LF. Removes some trailing whitespace as well.
Diffstat (limited to 'spec/functional/util')
-rw-r--r--spec/functional/util/powershell/cmdlet_spec.rb228
1 files changed, 114 insertions, 114 deletions
diff --git a/spec/functional/util/powershell/cmdlet_spec.rb b/spec/functional/util/powershell/cmdlet_spec.rb
index 71ad49d5f1..63d1ac09b5 100644
--- a/spec/functional/util/powershell/cmdlet_spec.rb
+++ b/spec/functional/util/powershell/cmdlet_spec.rb
@@ -1,114 +1,114 @@
-#
-# Author:: Adam Edwards (<adamed@getchef.com>)
-#
-# Copyright:: 2014, Chef Software, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-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(@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(@node, "$env:PROCESSOR_ARCHITECTURE")}
-
- it "executes a simple process" do
- result = simple_cmdlet.run
- expect(result.succeeded?).to eq(true)
- end
-
- it "#run does not raise a PowershellCmdletException exception if the command cannot be executed" do
- expect {invalid_cmdlet.run}.not_to raise_error
- end
-
- it "#run! raises a PowershellCmdletException exception if the command cannot be executed" do
- 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']
- if os_arch.nil?
- os_arch = ENV['PROCESSOR_ARCHITECTURE']
- end
-
- result = architecture_cmdlet.run
- execution_arch = result.return_value
- execution_arch.strip!
- expect(execution_arch).to eq(os_arch)
- end
-
- it "passes command line switches to the command" do
- result = cmdlet_alias_requires_switch_or_argument.run({:name => 'ls'})
- expect(result.succeeded?).to eq(true)
- end
-
- it "passes command line arguments to the command" do
- result = cmdlet_alias_requires_switch_or_argument.run({},{},'ls')
- expect(result.succeeded?).to eq(true)
- end
-
- it "passes command line arguments and switches to the command" do
- result = cmdlet_get_item_requires_switch_or_argument.run({:path => etc_directory},{},' | select-object -property fullname | format-table -hidetableheaders')
- expect(result.succeeded?).to eq(true)
- returned_directory = result.return_value
- returned_directory.strip!
- expect(returned_directory).to eq(etc_directory)
- end
-
- it "passes execution options to the command" do
- result = cmdlet_get_item_requires_switch_or_argument.run({},{:cwd => etc_directory},'. | select-object -property fullname | format-table -hidetableheaders')
- expect(result.succeeded?).to eq(true)
- returned_directory = result.return_value
- returned_directory.strip!
- expect(returned_directory).to eq(etc_directory)
- end
-
- context "when returning json" do
- let(:cmd_output_format) { :json }
- it "returns json format data", :windows_powershell_dsc_only do
- result = cmdlet_alias_requires_switch_or_argument.run({},{},'ls')
- expect(result.succeeded?).to eq(true)
- expect(lambda{JSON.parse(result.return_value)}).not_to raise_error
- end
- end
-
- context "when returning Ruby objects" do
- let(:cmd_output_format) { :object }
- it "returns object format data", :windows_powershell_dsc_only do
- result = simple_cmdlet.run({},{:cwd => etc_directory}, 'hosts')
- expect(result.succeeded?).to eq(true)
- data = result.return_value
- expect(data['Name']).to eq('hosts')
- end
- end
-
- context "when constructor is given invalid arguments" do
- let(:cmd_output_format) { :invalid }
- it "throws an exception if an invalid format is passed to the constructor" do
- expect(lambda{simple_cmdlet}).to raise_error
- end
- end
-end
+#
+# Author:: Adam Edwards (<adamed@getchef.com>)
+#
+# Copyright:: 2014, Chef Software, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+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(@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(@node, "$env:PROCESSOR_ARCHITECTURE")}
+
+ it "executes a simple process" do
+ result = simple_cmdlet.run
+ expect(result.succeeded?).to eq(true)
+ end
+
+ it "#run does not raise a PowershellCmdletException exception if the command cannot be executed" do
+ expect {invalid_cmdlet.run}.not_to raise_error
+ end
+
+ it "#run! raises a PowershellCmdletException exception if the command cannot be executed" do
+ 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']
+ if os_arch.nil?
+ os_arch = ENV['PROCESSOR_ARCHITECTURE']
+ end
+
+ result = architecture_cmdlet.run
+ execution_arch = result.return_value
+ execution_arch.strip!
+ expect(execution_arch).to eq(os_arch)
+ end
+
+ it "passes command line switches to the command" do
+ result = cmdlet_alias_requires_switch_or_argument.run({:name => 'ls'})
+ expect(result.succeeded?).to eq(true)
+ end
+
+ it "passes command line arguments to the command" do
+ result = cmdlet_alias_requires_switch_or_argument.run({},{},'ls')
+ expect(result.succeeded?).to eq(true)
+ end
+
+ it "passes command line arguments and switches to the command" do
+ result = cmdlet_get_item_requires_switch_or_argument.run({:path => etc_directory},{},' | select-object -property fullname | format-table -hidetableheaders')
+ expect(result.succeeded?).to eq(true)
+ returned_directory = result.return_value
+ returned_directory.strip!
+ expect(returned_directory).to eq(etc_directory)
+ end
+
+ it "passes execution options to the command" do
+ result = cmdlet_get_item_requires_switch_or_argument.run({},{:cwd => etc_directory},'. | select-object -property fullname | format-table -hidetableheaders')
+ expect(result.succeeded?).to eq(true)
+ returned_directory = result.return_value
+ returned_directory.strip!
+ expect(returned_directory).to eq(etc_directory)
+ end
+
+ context "when returning json" do
+ let(:cmd_output_format) { :json }
+ it "returns json format data", :windows_powershell_dsc_only do
+ result = cmdlet_alias_requires_switch_or_argument.run({},{},'ls')
+ expect(result.succeeded?).to eq(true)
+ expect(lambda{JSON.parse(result.return_value)}).not_to raise_error
+ end
+ end
+
+ context "when returning Ruby objects" do
+ let(:cmd_output_format) { :object }
+ it "returns object format data", :windows_powershell_dsc_only do
+ result = simple_cmdlet.run({},{:cwd => etc_directory}, 'hosts')
+ expect(result.succeeded?).to eq(true)
+ data = result.return_value
+ expect(data['Name']).to eq('hosts')
+ end
+ end
+
+ context "when constructor is given invalid arguments" do
+ let(:cmd_output_format) { :invalid }
+ it "throws an exception if an invalid format is passed to the constructor" do
+ expect(lambda{simple_cmdlet}).to raise_error
+ end
+ end
+end