diff options
-rw-r--r-- | spec/bundler/definition_spec.rb | 10 | ||||
-rw-r--r-- | spec/bundler/friendly_errors_spec.rb | 2 | ||||
-rw-r--r-- | spec/commands/binstubs_spec.rb | 2 | ||||
-rw-r--r-- | spec/commands/install_spec.rb | 2 | ||||
-rw-r--r-- | spec/install/deploy_spec.rb | 2 | ||||
-rw-r--r-- | spec/install/gemfile/path_spec.rb | 6 | ||||
-rw-r--r-- | spec/install/gems/compact_index_spec.rb | 2 | ||||
-rw-r--r-- | spec/install/gems/resolving_spec.rb | 6 | ||||
-rw-r--r-- | spec/install/gems/sudo_spec.rb | 2 | ||||
-rw-r--r-- | spec/runtime/setup_spec.rb | 80 | ||||
-rw-r--r-- | spec/support/helpers.rb | 6 |
11 files changed, 50 insertions, 70 deletions
diff --git a/spec/bundler/definition_spec.rb b/spec/bundler/definition_spec.rb index 92f836299d..1f4c1a0807 100644 --- a/spec/bundler/definition_spec.rb +++ b/spec/bundler/definition_spec.rb @@ -46,7 +46,7 @@ RSpec.describe Bundler::Definition do s.add_dependency "rack", "1.0" end - bundle :install, :env => { "DEBUG" => 1 } + bundle :install, :env => { "DEBUG" => "1" } expect(out).to match(/re-resolving dependencies/) lockfile_should_be <<-G @@ -84,7 +84,7 @@ RSpec.describe Bundler::Definition do s.add_dependency "rack", "1.0" end - bundle :install, :env => { "DEBUG" => 1 } + bundle :install, :env => { "DEBUG" => "1" } expect(out).to match(/re-resolving dependencies/) lockfile_should_be <<-G @@ -121,7 +121,7 @@ RSpec.describe Bundler::Definition do gem "foo", :path => "#{lib_path("foo")}" G - bundle :check, :env => { "DEBUG" => 1 } + bundle :check, :env => { "DEBUG" => "1" } expect(out).to match(/using resolution from the lockfile/) lockfile_should_be <<-G @@ -154,7 +154,7 @@ RSpec.describe Bundler::Definition do G bundle "lock --add-platform java" - bundle :check, :env => { "DEBUG" => 1 } + bundle :check, :env => { "DEBUG" => "1" } expect(out).to match(/using resolution from the lockfile/) lockfile_should_be <<-G @@ -181,7 +181,7 @@ RSpec.describe Bundler::Definition do gem "foo" G - bundle :check, :env => { "DEBUG" => 1 } + bundle :check, :env => { "DEBUG" => "1" } expect(out).to match(/using resolution from the lockfile/) lockfile_should_be <<-G diff --git a/spec/bundler/friendly_errors_spec.rb b/spec/bundler/friendly_errors_spec.rb index 47e7a5d3cd..e9189b0514 100644 --- a/spec/bundler/friendly_errors_spec.rb +++ b/spec/bundler/friendly_errors_spec.rb @@ -22,7 +22,7 @@ RSpec.describe Bundler, "friendly errors" do gem "rack" G - bundle :install, :env => { "DEBUG" => true } + bundle :install, :env => { "DEBUG" => "true" } expect(err).to include("Failed to load #{home(".gemrc")}") expect(exitstatus).to eq(0) if exitstatus diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb index df10bd3498..7c04e8ddbd 100644 --- a/spec/commands/binstubs_spec.rb +++ b/spec/commands/binstubs_spec.rb @@ -458,7 +458,7 @@ RSpec.describe "bundle binstubs <gem>" do G bundle "config set auto_install 1" - bundle "binstubs rack", :env => { "BUNDLE_INSTALL" => 1 } + bundle "binstubs rack", :env => { "BUNDLE_INSTALL" => "1" } expect(out).not_to include("Installing rack 1.0.0") end end diff --git a/spec/commands/install_spec.rb b/spec/commands/install_spec.rb index 8e161a4aae..b57d81b10a 100644 --- a/spec/commands/install_spec.rb +++ b/spec/commands/install_spec.rb @@ -45,7 +45,7 @@ RSpec.describe "bundle install with gem sources" do gem "rack" G - bundle! :install, :env => { "BUNDLE_PATH__SYSTEM" => true } # can't use install_gemfile since it sets retry + bundle! :install, :env => { "BUNDLE_PATH__SYSTEM" => "true" } # can't use install_gemfile since it sets retry expect(bundled_app(".bundle")).not_to exist end diff --git a/spec/install/deploy_spec.rb b/spec/install/deploy_spec.rb index d607f8bb46..89da3fc801 100644 --- a/spec/install/deploy_spec.rb +++ b/spec/install/deploy_spec.rb @@ -146,7 +146,7 @@ RSpec.describe "install with --deployment or --frozen" do expect(the_bundle).to include_gems "path_gem 1.0" FileUtils.rm_r lib_path("path_gem-1.0") - bundle! :install, forgotten_command_line_options(:path => ".bundle", :without => "development", :deployment => true).merge(:env => { :DEBUG => "1" }) + bundle! :install, forgotten_command_line_options(:path => ".bundle", :without => "development", :deployment => true).merge(:env => { "DEBUG" => "1" }) run! "puts :WIN" expect(out).to eq("WIN") end diff --git a/spec/install/gemfile/path_spec.rb b/spec/install/gemfile/path_spec.rb index 786b767354..e53636da09 100644 --- a/spec/install/gemfile/path_spec.rb +++ b/spec/install/gemfile/path_spec.rb @@ -439,7 +439,7 @@ RSpec.describe "bundle install with explicit source paths" do gem 'net-ssh', '1.0' G - bundle :check, :env => { "DEBUG" => 1 } + bundle :check, :env => { "DEBUG" => "1" } expect(out).to match(/using resolution from the lockfile/) expect(the_bundle).to include_gems "rack-obama 1.0", "net-ssh 1.0" end @@ -459,7 +459,7 @@ RSpec.describe "bundle install with explicit source paths" do gem 'net-ssh', :path => "#{lib_path("omg")}" G - bundle :check, :env => { "DEBUG" => 1 } + bundle :check, :env => { "DEBUG" => "1" } expect(out).to match(/using resolution from the lockfile/) expect(the_bundle).to include_gems "rack-obama 1.0", "net-ssh 1.0" end @@ -654,7 +654,7 @@ RSpec.describe "bundle install with explicit source paths" do File.open(lib_path("private_lib/Gemfile"), "w") {|f| f.puts gemfile } Dir.chdir(lib_path("private_lib")) do - bundle :install, :env => { "DEBUG" => 1 }, :artifice => "endpoint" + bundle :install, :env => { "DEBUG" => "1" }, :artifice => "endpoint" expect(out).to match(%r{^HTTP GET http://localgemserver\.test/api/v1/dependencies\?gems=rack$}) expect(out).not_to match(/^HTTP GET.*private_lib/) expect(the_bundle).to include_gems "private_lib 2.2" diff --git a/spec/install/gems/compact_index_spec.rb b/spec/install/gems/compact_index_spec.rb index 2c145ce643..a294b83d1c 100644 --- a/spec/install/gems/compact_index_spec.rb +++ b/spec/install/gems/compact_index_spec.rb @@ -51,7 +51,7 @@ RSpec.describe "compact index api" do build_gem "Rack", "0.1" end - install_gemfile! <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4 } + install_gemfile! <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } source "#{source_uri}" gem "rack", "1.0" gem "Rack", "0.1" diff --git a/spec/install/gems/resolving_spec.rb b/spec/install/gems/resolving_spec.rb index f7c72d7e31..52511ff67f 100644 --- a/spec/install/gems/resolving_spec.rb +++ b/spec/install/gems/resolving_spec.rb @@ -108,7 +108,7 @@ RSpec.describe "bundle install with install-time dependencies" do end end - install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2 } + install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s } ruby "#{RUBY_VERSION}" source "http://localgemserver.test/" gem 'rack' @@ -127,7 +127,7 @@ RSpec.describe "bundle install with install-time dependencies" do build_gem "foo1", "1.0" end - install_gemfile <<-G, :artifice => "compact_index_rate_limited", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4 } + install_gemfile <<-G, :artifice => "compact_index_rate_limited", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } ruby "#{RUBY_VERSION}" source "http://localgemserver.test/" gem 'rack' @@ -153,7 +153,7 @@ RSpec.describe "bundle install with install-time dependencies" do shared_examples_for "ruby version conflicts" do it "raises an error during resolution" do - install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2 } + install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s } source "http://localgemserver.test/" ruby #{ruby_requirement} gem 'require_ruby' diff --git a/spec/install/gems/sudo_spec.rb b/spec/install/gems/sudo_spec.rb index fcafe4a907..170ffaca03 100644 --- a/spec/install/gems/sudo_spec.rb +++ b/spec/install/gems/sudo_spec.rb @@ -172,7 +172,7 @@ RSpec.describe "when using sudo", :sudo => true do context "when ENV['BUNDLE_SILENCE_ROOT_WARNING'] is set" do it "skips the warning" do - bundle :install, :sudo => :preserve_env, :env => { "BUNDLE_SILENCE_ROOT_WARNING" => true } + bundle :install, :sudo => :preserve_env, :env => { "BUNDLE_SILENCE_ROOT_WARNING" => "true" } expect(err).to_not include(warning) end end diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index e247feb804..80c38e9f4a 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -864,7 +864,7 @@ end G Dir.chdir(bundled_app.parent) do - run <<-R, :env => { "BUNDLE_GEMFILE" => bundled_app("Gemfile") } + run <<-R, :env => { "BUNDLE_GEMFILE" => bundled_app("Gemfile").to_s } require 'foo' R end @@ -888,7 +888,7 @@ end bundle :install Dir.chdir(bundled_app.parent) do - run <<-R, :env => { "BUNDLE_GEMFILE" => bundled_app("Gemfile") } + run <<-R, :env => { "BUNDLE_GEMFILE" => bundled_app("Gemfile").to_s } require 'foo' R end @@ -1212,17 +1212,15 @@ end let(:activation_warning_hack) { strip_whitespace(<<-RUBY) } require #{spec_dir.join("support/hax").to_s.dump} - if Gem::Specification.instance_methods.map(&:to_sym).include?(:activate) - Gem::Specification.send(:alias_method, :bundler_spec_activate, :activate) - Gem::Specification.send(:define_method, :activate) do - unless #{exemptions.inspect}.include?(name) - warn '-' * 80 - warn "activating \#{full_name}" - warn *caller - warn '*' * 80 - end - bundler_spec_activate + Gem::Specification.send(:alias_method, :bundler_spec_activate, :activate) + Gem::Specification.send(:define_method, :activate) do + unless #{exemptions.inspect}.include?(name) + warn '-' * 80 + warn "activating \#{full_name}" + warn(*caller) + warn '*' * 80 end + bundler_spec_activate end RUBY @@ -1246,14 +1244,14 @@ end it "activates no gems with -rbundler/setup" do install_gemfile! "" - ruby! code, :env => { :RUBYOPT => activation_warning_hack_rubyopt + " -r#{lib_dir}/bundler/setup" } + ruby! code, :env => { "RUBYOPT" => activation_warning_hack_rubyopt + " -r#{lib_dir}/bundler/setup" } expect(out).to eq("{}") end it "activates no gems with bundle exec" do install_gemfile! "" create_file("script.rb", code) - bundle! "exec ruby ./script.rb", :env => { :RUBYOPT => activation_warning_hack_rubyopt } + bundle! "exec ruby ./script.rb", :env => { "RUBYOPT" => activation_warning_hack_rubyopt } expect(out).to eq("{}") end @@ -1261,54 +1259,40 @@ end install_gemfile! "" create_file("script.rb", "#!/usr/bin/env ruby\n\n#{code}") FileUtils.chmod(0o777, bundled_app("script.rb")) - bundle! "exec ./script.rb", :artifice => nil, :env => { :RUBYOPT => activation_warning_hack_rubyopt } + bundle! "exec ./script.rb", :artifice => nil, :env => { "RUBYOPT" => activation_warning_hack_rubyopt } expect(out).to eq("{}") end - let(:default_gems) do - ruby!(<<-RUBY).split("\n") - if Gem::Specification.is_a?(Enumerable) - puts Gem::Specification.select(&:default_gem?).map(&:name) - end - RUBY - end + Gem::Specification.select(&:default_gem?).map(&:name).each do |g| + it "activates newer versions of #{g}" do + skip if exemptions.include?(g) - it "activates newer versions of default gems" do - build_repo4 do - default_gems.each do |g| + build_repo4 do build_gem g, "999999" end - end - default_gems.reject! {|g| exemptions.include?(g) } + install_gemfile! <<-G + source "#{file_uri_for(gem_repo4)}" + gem "#{g}", "999999" + G - install_gemfile! <<-G - source "#{file_uri_for(gem_repo4)}" - #{default_gems}.each do |g| - gem g, "999999" - end - G + expect(the_bundle).to include_gem("#{g} 999999", :env => { "RUBYOPT" => activation_warning_hack_rubyopt }) + end - expect(the_bundle).to include_gems(*default_gems.map {|g| "#{g} 999999" }) - end + it "activates older versions of #{g}" do + skip if exemptions.include?(g) - it "activates older versions of default gems" do - build_repo4 do - default_gems.each do |g| + build_repo4 do build_gem g, "0.0.0.a" end - end - default_gems.reject! {|g| exemptions.include?(g) } - - install_gemfile! <<-G - source "#{file_uri_for(gem_repo4)}" - #{default_gems}.each do |g| - gem g, "0.0.0.a" - end - G + install_gemfile! <<-G + source "#{file_uri_for(gem_repo4)}" + gem "#{g}", "0.0.0.a" + G - expect(the_bundle).to include_gems(*default_gems.map {|g| "#{g} 0.0.0.a" }) + expect(the_bundle).to include_gem("#{g} 0.0.0.a", :env => { "RUBYOPT" => activation_warning_hack_rubyopt }) + end end end end diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 95c2d60d56..7d1bd65185 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -23,9 +23,7 @@ module Spec define_method("#{method}!") do |*args, &blk| send(method, *args, &blk).tap do unless last_command.success? - raise RuntimeError, - "Invoking #{method}!(#{args.map(&:inspect).join(", ")}) failed:\n#{last_command.stdboth}", - caller.drop_while {|bt| bt.start_with?(__FILE__) } + raise "Invoking #{method}!(#{args.map(&:inspect).join(", ")}) failed:\n#{last_command.stdboth}" end end end @@ -207,8 +205,6 @@ module Spec def sys_exec(cmd, env = {}) command_execution = CommandExecution.new(cmd.to_s, Dir.pwd) - env = env.map {|k, v| [k.to_s, v.to_s] }.to_h # convert env keys and values to string - require "open3" Open3.popen3(env, cmd.to_s) do |stdin, stdout, stderr, wait_thr| yield stdin, stdout, wait_thr if block_given? |