Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Commit

Permalink
Actually pass through the user property for bundle_install.
Browse files Browse the repository at this point in the history
  • Loading branch information
coderanger committed Aug 24, 2015
1 parent d0c147d commit bcb901d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/poise_ruby/resources/bundle_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class Resource < Chef::Resource
attribute(:retry, kind_of: [String, Integer])
# @!attribute user
# User to run bundler as.
# @return [String]
attribute(:user, kind_of: String)
# @return [String, Integery, nil]
attribute(:user, kind_of: [String, Integer, NilClass])
# @!attribute vendor
# Enable local vendoring. This maps to the `--path` option in bundler,
# but that attribute name is already used.
Expand Down Expand Up @@ -157,7 +157,7 @@ def gemfile_path
# Install the gems in the Gemfile.
def run_bundler(command)
return converge_by "Run bundle #{command}" if whyrun_mode?
cmd = ruby_shell_out!(bundler_command(command), environment: {'BUNDLE_GEMFILE' => gemfile_path})
cmd = ruby_shell_out!(bundler_command(command), environment: {'BUNDLE_GEMFILE' => gemfile_path}, user: new_resource.user)
# Look for a line like 'Installing $gemname $version' to know if we did anything.
if cmd.stdout.include?('Installing')
new_resource.updated_by_last_action(true)
Expand Down
4 changes: 2 additions & 2 deletions test/spec/resources/bundle_install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
end # /describe PoiseRuby::Resources::BundleInstall::Resource

describe PoiseRuby::Resources::BundleInstall::Provider do
let(:new_resource) { double('new_resource', parent_ruby: nil, timeout: 900, ruby: '/usr/bin/ruby') }
let(:new_resource) { double('new_resource', parent_ruby: nil, timeout: 900, ruby: '/usr/bin/ruby', user: nil) }
let(:provider) { described_class.new(new_resource, nil) }

describe '#action_install' do
Expand All @@ -63,7 +63,7 @@
before do
allow(provider).to receive(:bundler_command).and_return(%w{bundle install})
allow(provider).to receive(:gemfile_path).and_return('Gemfile')
expect(provider).to receive(:ruby_shell_out!).with(%w{bundle install}, environment: {'BUNDLE_GEMFILE' => 'Gemfile'}).and_return(double(stdout: bundle_output))
expect(provider).to receive(:ruby_shell_out!).with(%w{bundle install}, environment: {'BUNDLE_GEMFILE' => 'Gemfile'}, user: nil).and_return(double(stdout: bundle_output))
end

context 'with a new gem' do
Expand Down

0 comments on commit bcb901d

Please sign in to comment.