summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2019-02-23 21:25:22 +0100
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-03-28 15:27:41 +0100
commit776ad6238a35710abcf242786bdb40236a9a27f7 (patch)
tree099158a7bbcacb28b073825d07d9b9599e546eb5
parent2167156db020fbe6ce74759cbf62ad1ceb651fb7 (diff)
downloadbundler-simplify_gems_used_by_tests_installation.tar.gz
Tests automatically download and install the test gems they need if not installed, so this should be unnecessary. However, removing it create a single spec failure only reproducible on a fresh clone (where the path where the test gems are installed, `tmp/gems`, has not yet been populated. The problem was that the code branch that installs the gems uses the `FileUtils` constant. Accessing that constant makes [this autoload] trigger the custom rubygems `require` behavior which will end up setting and memoizing `gem_home` to the value it has at that point (when calling `to_spec` on the selected default gem). But at that point, `Gem.clear_paths` call has already happened, that means `gem_home` won't be changed during the duration of the test because it's memoized. This situation makes a specific test that updates `ENV["HOME"]` and expects he path to the configuration file rubygems uses to be updated fail. This could be fixed by removing the `FileUtils` autoload, or stop memoizing `Gem.home`, but the simplest fix seemed to require `fileutils` early, so that `Gem.home` is not memoized again after calling `Gem.clear_paths`. [this autoload]: https://github.com/rubygems/rubygems/blob/511a0f5105ca95b8e389bf477b6c7cf3e90be7d1/lib/rubygems/source.rb#L3
-rw-r--r--Rakefile5
-rw-r--r--spec/support/rubygems_ext.rb1
2 files changed, 1 insertions, 5 deletions
diff --git a/Rakefile b/Rakefile
index 0a4d9c8900..105faf927d 100644
--- a/Rakefile
+++ b/Rakefile
@@ -54,11 +54,6 @@ namespace :spec do
"'#{name}:#{version}'"
end.join(" ")
sh %(#{Gem.ruby} -S gem #{gem_install_command})
-
- # Download and install gems used inside tests
- $LOAD_PATH.unshift("./spec")
- require "support/rubygems_ext"
- Spec::Rubygems.setup
end
namespace :travis do
diff --git a/spec/support/rubygems_ext.rb b/spec/support/rubygems_ext.rb
index edd66278ad..2f3d252865 100644
--- a/spec/support/rubygems_ext.rb
+++ b/spec/support/rubygems_ext.rb
@@ -2,6 +2,7 @@
require "rubygems/user_interaction"
require "support/path"
+require "fileutils"
module Spec
module Rubygems