summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlucywyman <wyman.lucy@gmail.com>2014-11-19 13:38:29 -0800
committerlucywyman <wyman.lucy@gmail.com>2014-11-19 13:38:29 -0800
commit924d75fd5b79b03e623cc657c5bef73e96f94465 (patch)
tree9269215631961400949780c568a866ce6caa17da
parent9179b18eeb2e476480fd0a4a4a5f8b36f75e5982 (diff)
downloadchef-924d75fd5b79b03e623cc657c5bef73e96f94465.tar.gz
Setting version to an empty string in tests
Check for nil and length on version in package/rubygems tests In gemspec test change @new_resource.instance_variable_set() to @new_resource.version()
-rw-r--r--lib/chef/provider/package/rubygems.rb2
-rw-r--r--spec/unit/provider/package/rubygems_spec.rb8
2 files changed, 9 insertions, 1 deletions
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/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')