summaryrefslogtreecommitdiff
path: root/spec/plugins/install_spec.rb
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2020-01-10 09:56:42 +0100
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2020-01-12 20:46:33 +0100
commit7dc38a75680f991bf32320cca850c32d1dcd90ca (patch)
treee532f1f4eb42a0b9f438ef40380a1ab9ae810975 /spec/plugins/install_spec.rb
parent55630c23f4e0683e820116af917888cf23569020 (diff)
downloadbundler-tests/less_flakyness.tar.gz
Remove global directory switching from specstests/less_flakyness
`Dir.chdir` is not thread safe, so it makes our parallel specs flaky. Instead, use the following alternatives: * Use `:chdir` parameter to `Open3` methods for specs that shell out. * Stub `find_gemfile` or other relevant helpers for unit tests.
Diffstat (limited to 'spec/plugins/install_spec.rb')
-rw-r--r--spec/plugins/install_spec.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/spec/plugins/install_spec.rb b/spec/plugins/install_spec.rb
index 669ed09fb5..663363ca21 100644
--- a/spec/plugins/install_spec.rb
+++ b/spec/plugins/install_spec.rb
@@ -155,6 +155,10 @@ RSpec.describe "bundler plugin install" do
end
context "Gemfile eval" do
+ before do
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
+ end
+
it "installs plugins listed in gemfile" do
gemfile <<-G
source '#{file_uri_for(gem_repo2)}'
@@ -245,6 +249,7 @@ RSpec.describe "bundler plugin install" do
describe "local plugin" do
it "is installed when inside an app" do
+ allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
gemfile ""
bundle "plugin install foo --source #{file_uri_for(gem_repo2)}"
@@ -287,21 +292,16 @@ RSpec.describe "bundler plugin install" do
end
# outside the app
- Dir.chdir tmp
- bundle "plugin install fubar --source #{file_uri_for(gem_repo2)}"
+ bundle "plugin install fubar --source #{file_uri_for(gem_repo2)}", :dir => tmp
end
it "inside the app takes precedence over global plugin" do
- Dir.chdir bundled_app
-
bundle "shout"
expect(out).to eq("local_one")
end
it "outside the app global plugin is used" do
- Dir.chdir tmp
-
- bundle "shout"
+ bundle "shout", :dir => tmp
expect(out).to eq("global_one")
end
end