summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md4
-rw-r--r--lib/chef/knife/core/bootstrap_context.rb2
-rw-r--r--lib/chef/provider/package/rubygems.rb2
-rw-r--r--spec/unit/knife/core/bootstrap_context_spec.rb14
-rw-r--r--spec/unit/provider/package/rubygems_spec.rb8
5 files changed, 28 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e85a727c37..25c7172a12 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,10 @@
removed securerandom patch
* [**Scott Bonds**](https://github.com/bonds)
add package support for OpenBSD
+* [**Lucy Wyman**](https://github.com/lucywyman)
+ Added support for handling empty version strings to rubygems provider.
+* [**Yulian Kuncheff**](https://github.com/Daegalus)
+ Correctly set the pre-release identifier during knife bootstrap.
### Chef Contributions
* Update Chef to use RSpec 3.
diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb
index e681d7a49b..ce062bdd25 100644
--- a/lib/chef/knife/core/bootstrap_context.rb
+++ b/lib/chef/knife/core/bootstrap_context.rb
@@ -135,7 +135,7 @@ CONFIG
def latest_current_chef_version_string
installer_version_string = nil
if @config[:prerelease]
- installer_version_string = "-p"
+ installer_version_string = ["-p"]
else
chef_version_string = if knife_config[:bootstrap_version]
knife_config[:bootstrap_version]
diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb
index 6304a7ef63..dd731adee4 100644
--- a/lib/chef/provider/package/rubygems.rb
+++ b/lib/chef/provider/package/rubygems.rb
@@ -536,7 +536,7 @@ class Chef
else
src = @new_resource.source && " --source=#{@new_resource.source} --source=https://rubygems.org"
end
- if version
+ if !version.nil? && version.length > 0
shell_out!("#{gem_binary_path} install #{name} -q --no-rdoc --no-ri -v \"#{version}\"#{src}#{opts}", :env=>nil)
else
shell_out!("#{gem_binary_path} install \"#{name}\" -q --no-rdoc --no-ri #{src}#{opts}", :env=>nil)
diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb
index 1291571358..af8fa3f698 100644
--- a/spec/unit/knife/core/bootstrap_context_spec.rb
+++ b/spec/unit/knife/core/bootstrap_context_spec.rb
@@ -205,4 +205,18 @@ EXPECTED
end
end
+ describe "prerelease" do
+ it "isn't set in the config_content by default" do
+ expect(bootstrap_context.config_content).not_to include("prerelease")
+ end
+
+ describe "when configured via cli" do
+ let(:config) {{:prerelease => true}}
+
+ it "uses CLI value" do
+ expect(bootstrap_context.latest_current_chef_version_string).to eq("-p")
+ end
+ end
+ end
+
end
diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb
index a3a4772229..b4960b2af3 100644
--- a/spec/unit/provider/package/rubygems_spec.rb
+++ b/spec/unit/provider/package/rubygems_spec.rb
@@ -536,6 +536,14 @@ describe Chef::Provider::Package::Rubygems do
expect(@provider.action_install).to be_truthy
end
+ it "installs the gem by shelling out when options are provided but no version is given" do
+ @new_resource.options('-i /alt/install/location')
+ @new_resource.version('')
+ expected ="gem install \"rspec-core\" -q --no-rdoc --no-ri -i /alt/install/location"
+ expect(@provider).to receive(:shell_out!).with(expected, :env => nil)
+ expect(@provider.action_install).to be_truthy
+ end
+
it "installs the gem via the gems api when options are given as a Hash" do
@new_resource.options(:install_dir => '/alt/install/location')
expect(@provider.gem_env).to receive(:install).with(@gem_dep, :sources => nil, :install_dir => '/alt/install/location')