summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornimisha <nimisha.sharad@msystechnologies.com>2017-05-11 21:44:38 +0530
committernimisha <nimisha.sharad@msystechnologies.com>2017-05-11 21:56:28 +0530
commit707ffe04e34f37716a20e8c7099bafc27677894b (patch)
treebeabaac1d177699fb8bf69971c4f393819377d5e
parentbc8f7d1f62b121589d5f6f10ff7aa536bd4af430 (diff)
downloadchef-707ffe04e34f37716a20e8c7099bafc27677894b.tar.gz
Added choco_include? filter
Signed-off-by: nimisha <nimisha.sharad@msystechnologies.com>
-rw-r--r--spec/functional/resource/chocolatey_package_spec.rb9
-rw-r--r--spec/functional/resource/windows_task_spec.rb4
-rw-r--r--spec/spec_helper.rb2
-rw-r--r--spec/support/platform_helpers.rb7
4 files changed, 12 insertions, 10 deletions
diff --git a/spec/functional/resource/chocolatey_package_spec.rb b/spec/functional/resource/chocolatey_package_spec.rb
index 7bb6698daf..e8dae581b9 100644
--- a/spec/functional/resource/chocolatey_package_spec.rb
+++ b/spec/functional/resource/chocolatey_package_spec.rb
@@ -18,16 +18,9 @@
require "spec_helper"
require "chef/mixin/powershell_out"
-describe Chef::Resource::ChocolateyPackage, :windows_only do
+describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
include Chef::Mixin::PowershellOut
- before(:all) do
- powershell_out!("iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))")
- unless ENV["PATH"] =~ /chocolatey\\bin/
- ENV["PATH"] = "C:\\ProgramData\\chocolatey\\bin;#{ENV["PATH"]}"
- end
- end
-
let(:package_name) { "test-A" }
let(:package_list) { proc { powershell_out!("choco list -lo -r #{Array(package_name).join(' ')}").stdout.chomp } }
let(:package_source) { File.join(CHEF_SPEC_ASSETS, "chocolatey_feed") }
diff --git a/spec/functional/resource/windows_task_spec.rb b/spec/functional/resource/windows_task_spec.rb
index 287a72169f..da98fa3145 100644
--- a/spec/functional/resource/windows_task_spec.rb
+++ b/spec/functional/resource/windows_task_spec.rb
@@ -387,8 +387,8 @@ describe Chef::Resource::WindowsTask, :windows_only do
new_resource
end
- it "runs the existing task" do
- pending "Task status is returned as Ready instead of Running randomly"
+ xit "runs the existing task" do
+ # Task status is returned as Ready instead of Running randomly
subject.run_action(:create)
subject.run_action(:run)
task_details = windows_task_provider.send(:load_task_hash, task_name)
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 8e1faa3060..edb5491100 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -182,6 +182,8 @@ RSpec.configure do |config|
config.filter_run_excluding chef: DependencyProc.with(Chef::VERSION)
config.filter_run_excluding ruby: DependencyProc.with(RUBY_VERSION)
+ config.filter_run_excluding :choco_installed => true unless choco_installed?
+
running_platform_arch = `uname -m`.strip unless windows?
config.filter_run_excluding :arch => lambda { |target_arch|
diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb
index 120e73740d..019cb9a912 100644
--- a/spec/support/platform_helpers.rb
+++ b/spec/support/platform_helpers.rb
@@ -2,9 +2,11 @@ require "fcntl"
require "chef/mixin/shell_out"
require "ohai/mixin/http_helper"
require "ohai/mixin/gce_metadata"
+require "chef/mixin/powershell_out"
class ShellHelpers
extend Chef::Mixin::ShellOut
+ extend Chef::Mixin::PowershellOut
end
# magic stolen from bundler/spec/support/less_than_proc.rb
@@ -231,3 +233,8 @@ def gce?
rescue SocketError
false
end
+
+def choco_installed?
+ result = ShellHelpers.powershell_out("choco --version")
+ result.stderr.empty? ? true : false
+end