diff options
author | Andre Arko <andre@arko.net> | 2014-04-07 17:20:20 +0900 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2014-04-07 17:20:20 +0900 |
commit | 17f4a87ce64e15f0920e7c7db692e51a3ae152a6 (patch) | |
tree | 7002e7aeec61edbf91a5de5eca7f3d7310e25c4a /spec | |
parent | 5dcdeb0c4ffe384922abe5136f103522197d8343 (diff) | |
download | bundler-17f4a87ce64e15f0920e7c7db692e51a3ae152a6.tar.gz |
root warn spec to sudo specs
Diffstat (limited to 'spec')
-rw-r--r-- | spec/bundler/cli_spec.rb | 24 | ||||
-rw-r--r-- | spec/install/gems/sudo_spec.rb | 8 | ||||
-rw-r--r-- | spec/support/helpers.rb | 5 |
3 files changed, 11 insertions, 26 deletions
diff --git a/spec/bundler/cli_spec.rb b/spec/bundler/cli_spec.rb index e0aef4a600..ef4ec79656 100644 --- a/spec/bundler/cli_spec.rb +++ b/spec/bundler/cli_spec.rb @@ -4,30 +4,6 @@ require 'bundler/cli' describe "bundle executable" do let(:source_uri) { "http://localgemserver.test" } - context "#warn_if_root" do - it "warns the user when install is run as root" do - expect(Process).to receive(:uid).and_return(0) - - gemfile <<-G - source "#{source_uri}" - G - - warning = <<-W - -WARNING **************************************************************** -Running bundler with sudo will likely have unintended consequences. -If bundler requires you to run a command with sudo it will let you know. -************************************************************************ - - W - - output = capture_output { - Bundler::CLI.new.warn_if_root - } - expect(output).to include(warning) - end - end - it "returns non-zero exit status when passed unrecognized options" do bundle '--invalid_argument', :exitstatus => true expect(exitstatus).to_not be_zero diff --git a/spec/install/gems/sudo_spec.rb b/spec/install/gems/sudo_spec.rb index 2c92745a17..366432188b 100644 --- a/spec/install/gems/sudo_spec.rb +++ b/spec/install/gems/sudo_spec.rb @@ -125,4 +125,12 @@ describe "when using sudo", :sudo => true do end end + describe "and root runs install" do + it "warns against that" do + gemfile %|source "file://#{gem_repo1}"| + bundle :install, :sudo => true + expect(out).to include("Don't run Bundler as root.") + end + end + end diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 865f3241a9..9c15783822 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -58,6 +58,7 @@ module Spec def bundle(cmd, options = {}) expect_err = options.delete(:expect_err) exitstatus = options.delete(:exitstatus) + sudo = "sudo" if options.delete(:sudo) options["no-color"] = true unless options.key?("no-color") || %w(exec conf).include?(cmd.to_s[0..3]) bundle_bin = File.expand_path('../../../bin/bundle', __FILE__) @@ -67,12 +68,12 @@ module Spec requires << File.expand_path('../artifice/'+options.delete(:artifice)+'.rb', __FILE__) if options.key?(:artifice) requires_str = requires.map{|r| "-r#{r}"}.join(" ") - env = (options.delete(:env) || {}).map{|k,v| "#{k}='#{v}' "}.join + env = (options.delete(:env) || {}).map{|k,v| "#{k}='#{v}'"}.join(" ") args = options.map do |k,v| v == true ? " --#{k}" : " --#{k} #{v}" if v end.join - cmd = "#{env}#{Gem.ruby} -I#{lib} #{requires_str} #{bundle_bin} #{cmd}#{args}" + cmd = "#{env} #{sudo} #{Gem.ruby} -I#{lib} #{requires_str} #{bundle_bin} #{cmd}#{args}" if exitstatus sys_status(cmd) |