summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Preston <stuart@chef.io>2018-04-21 09:04:16 +0200
committerStuart Preston <stuart@chef.io>2018-04-21 09:04:16 +0200
commit1b88dea1e0b7771251ac4ba75590f64e6d6cb7ae (patch)
tree928f44c84bc935b90d7ed521abde7645b2746493
parentd6b8aa701aea18db31b4d9ec2943aa6bfb0efc4e (diff)
downloadchef-1b88dea1e0b7771251ac4ba75590f64e6d6cb7ae.tar.gz
Fixing specs for powershell_packagesp/fix7166
Signed-off-by: Stuart Preston <stuart@chef.io>
-rw-r--r--lib/chef/provider/package/powershell.rb2
-rw-r--r--spec/unit/provider/package/powershell_spec.rb38
2 files changed, 20 insertions, 20 deletions
diff --git a/lib/chef/provider/package/powershell.rb b/lib/chef/provider/package/powershell.rb
index a7aa6cb223..44b6e69a00 100644
--- a/lib/chef/provider/package/powershell.rb
+++ b/lib/chef/provider/package/powershell.rb
@@ -36,7 +36,7 @@ class Chef
def define_resource_requirements
super
- if node['languages']['powershell']['version'].to_i < 5
+ if powershell_out("$PSVersionTable.PSVersion.Major").stdout.strip.to_i < 5
raise "Minimum installed Powershell Version required is 5"
end
requirements.assert(:install) do |a|
diff --git a/spec/unit/provider/package/powershell_spec.rb b/spec/unit/provider/package/powershell_spec.rb
index 9bebfa9194..534b7b6b13 100644
--- a/spec/unit/provider/package/powershell_spec.rb
+++ b/spec/unit/provider/package/powershell_spec.rb
@@ -192,88 +192,88 @@ describe Chef::Provider::Package::Powershell do
end
- describe "#build_powershell_command" do
+ describe "#build_powershell_package_command" do
it "can build a valid command from a single string" do
- expect(provider.build_powershell_command("Get-Package posh-git")).to eql(generated_command)
+ expect(provider.build_powershell_package_command("Get-Package posh-git")).to eql(generated_command)
end
it "can build a valid command from an array" do
- expect(provider.build_powershell_command(["Get-Package", "posh-git"])).to eql(generated_command)
+ expect(provider.build_powershell_package_command(["Get-Package", "posh-git"])).to eql(generated_command)
end
context "when source is nil" do
it "build get commands correctly" do
- expect(provider.build_powershell_command("Get-Package xNetworking")).to eql(generated_get_cmdlet)
+ expect(provider.build_powershell_package_command("Get-Package xNetworking")).to eql(generated_get_cmdlet)
end
it "build get commands correctly when a version is passed" do
- expect(provider.build_powershell_command("Get-Package xNetworking", "1.0.0.0")).to eql(generated_get_cmdlet_with_version)
+ expect(provider.build_powershell_package_command("Get-Package xNetworking", "1.0.0.0")).to eql(generated_get_cmdlet_with_version)
end
it "builds find commands correctly" do
- expect(provider.build_powershell_command("Find-Package xNetworking")).to eql(generated_find_cmdlet)
+ expect(provider.build_powershell_package_command("Find-Package xNetworking")).to eql(generated_find_cmdlet)
end
it "builds find commands correctly when a version is passed" do
- expect(provider.build_powershell_command("Find-Package xNetworking", "1.0.0.0")).to eql(generated_find_cmdlet_with_version)
+ expect(provider.build_powershell_package_command("Find-Package xNetworking", "1.0.0.0")).to eql(generated_find_cmdlet_with_version)
end
it "build install commands correctly" do
- expect(provider.build_powershell_command("Install-Package xNetworking")).to eql(generated_install_cmdlet)
+ expect(provider.build_powershell_package_command("Install-Package xNetworking")).to eql(generated_install_cmdlet)
end
it "build install commands correctly when a version is passed" do
- expect(provider.build_powershell_command("Install-Package xNetworking", "1.0.0.0")).to eql(generated_install_cmdlet_with_version)
+ expect(provider.build_powershell_package_command("Install-Package xNetworking", "1.0.0.0")).to eql(generated_install_cmdlet_with_version)
end
it "build install commands correctly" do
- expect(provider.build_powershell_command("Uninstall-Package xNetworking")).to eql(generated_uninstall_cmdlet)
+ expect(provider.build_powershell_package_command("Uninstall-Package xNetworking")).to eql(generated_uninstall_cmdlet)
end
it "build install commands correctly when a version is passed" do
- expect(provider.build_powershell_command("Uninstall-Package xNetworking", "1.0.0.0")).to eql(generated_uninstall_cmdlet_with_version)
+ expect(provider.build_powershell_package_command("Uninstall-Package xNetworking", "1.0.0.0")).to eql(generated_uninstall_cmdlet_with_version)
end
end
context "when source is set" do
it "build get commands correctly" do
new_resource.source("MyGallery")
- expect(provider.build_powershell_command("Get-Package xNetworking")).to eql(generated_get_cmdlet)
+ expect(provider.build_powershell_package_command("Get-Package xNetworking")).to eql(generated_get_cmdlet)
end
it "build get commands correctly when a version is passed" do
new_resource.source("MyGallery")
- expect(provider.build_powershell_command("Get-Package xNetworking", "1.0.0.0")).to eql(generated_get_cmdlet_with_version)
+ expect(provider.build_powershell_package_command("Get-Package xNetworking", "1.0.0.0")).to eql(generated_get_cmdlet_with_version)
end
it "builds find commands correctly" do
new_resource.source("MyGallery")
- expect(provider.build_powershell_command("Find-Package xNetworking")).to eql(generated_find_cmdlet_with_source)
+ expect(provider.build_powershell_package_command("Find-Package xNetworking")).to eql(generated_find_cmdlet_with_source)
end
it "builds find commands correctly when a version is passed" do
new_resource.source("MyGallery")
- expect(provider.build_powershell_command("Find-Package xNetworking", "1.0.0.0")).to eql(generated_find_cmdlet_with_source_and_version)
+ expect(provider.build_powershell_package_command("Find-Package xNetworking", "1.0.0.0")).to eql(generated_find_cmdlet_with_source_and_version)
end
it "build install commands correctly" do
new_resource.source("MyGallery")
- expect(provider.build_powershell_command("Install-Package xNetworking")).to eql(generated_install_cmdlet_with_source)
+ expect(provider.build_powershell_package_command("Install-Package xNetworking")).to eql(generated_install_cmdlet_with_source)
end
it "build install commands correctly when a version is passed" do
new_resource.source("MyGallery")
- expect(provider.build_powershell_command("Install-Package xNetworking", "1.0.0.0")).to eql(generated_install_cmdlet_with_source_and_version)
+ expect(provider.build_powershell_package_command("Install-Package xNetworking", "1.0.0.0")).to eql(generated_install_cmdlet_with_source_and_version)
end
it "build install commands correctly" do
new_resource.source("MyGallery")
- expect(provider.build_powershell_command("Uninstall-Package xNetworking")).to eql(generated_uninstall_cmdlet)
+ expect(provider.build_powershell_package_command("Uninstall-Package xNetworking")).to eql(generated_uninstall_cmdlet)
end
it "build install commands correctly when a version is passed" do
new_resource.source("MyGallery")
- expect(provider.build_powershell_command("Uninstall-Package xNetworking", "1.0.0.0")).to eql(generated_uninstall_cmdlet_with_version)
+ expect(provider.build_powershell_package_command("Uninstall-Package xNetworking", "1.0.0.0")).to eql(generated_uninstall_cmdlet_with_version)
end
end
end