summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2020-03-10 15:39:37 +0100
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2020-03-10 17:19:44 +0100
commit05725a9bacc56ef5ff811dabadecce016383a886 (patch)
tree548ffe0bfbfaeb519b9672c8b8f29288e0c71a0f
parent00da5215e90c6483728e077df4e90ab6cd34c35d (diff)
downloadbundler-config_location.tar.gz
Use thread safe method to find cwdconfig_location
And stub that in plugin's specs.
-rw-r--r--lib/bundler/shared_helpers.rb2
-rw-r--r--spec/bundler/plugin/index_spec.rb2
-rw-r--r--spec/bundler/plugin_spec.rb5
-rw-r--r--spec/plugins/install_spec.rb4
-rw-r--r--spec/plugins/source_spec.rb6
5 files changed, 10 insertions, 9 deletions
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index 960a935cd3..327de0d835 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -23,7 +23,7 @@ module Bundler
def config_root
bundle_dir = default_bundle_dir
- bundle_dir ? bundle_dir.parent : Pathname.pwd
+ bundle_dir ? bundle_dir.parent : pwd
end
def default_gemfile
diff --git a/spec/bundler/plugin/index_spec.rb b/spec/bundler/plugin/index_spec.rb
index 925dc558ac..ae64756298 100644
--- a/spec/bundler/plugin/index_spec.rb
+++ b/spec/bundler/plugin/index_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe Bundler::Plugin::Index do
Index = Bundler::Plugin::Index
before do
- allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
+ allow(Bundler::SharedHelpers).to receive(:pwd).and_return(bundled_app)
gemfile ""
path = lib_path(plugin_name)
index.register_plugin("new-plugin", path.to_s, [path.join("lib").to_s], commands, sources, hooks)
diff --git a/spec/bundler/plugin_spec.rb b/spec/bundler/plugin_spec.rb
index 8c95723bcc..9341b4ada3 100644
--- a/spec/bundler/plugin_spec.rb
+++ b/spec/bundler/plugin_spec.rb
@@ -237,7 +237,8 @@ RSpec.describe Bundler::Plugin do
describe "#root" do
context "in app dir" do
before do
- allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
+ allow(Bundler::SharedHelpers).to receive(:pwd).and_return(bundled_app)
+ FileUtils.touch(bundled_app.join("Gemfile"))
end
it "returns plugin dir in app .bundle path" do
@@ -247,7 +248,7 @@ RSpec.describe Bundler::Plugin do
context "outside app dir" do
before do
- allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(nil)
+ allow(Bundler::SharedHelpers).to receive(:pwd).and_return(root)
end
it "returns plugin dir in global bundle path" do
diff --git a/spec/plugins/install_spec.rb b/spec/plugins/install_spec.rb
index 663363ca21..804a3828e5 100644
--- a/spec/plugins/install_spec.rb
+++ b/spec/plugins/install_spec.rb
@@ -156,7 +156,7 @@ RSpec.describe "bundler plugin install" do
context "Gemfile eval" do
before do
- allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
+ allow(Bundler::SharedHelpers).to receive(:pwd).and_return(bundled_app)
end
it "installs plugins listed in gemfile" do
@@ -249,7 +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)
+ allow(Bundler::SharedHelpers).to receive(:pwd).and_return(bundled_app)
gemfile ""
bundle "plugin install foo --source #{file_uri_for(gem_repo2)}"
diff --git a/spec/plugins/source_spec.rb b/spec/plugins/source_spec.rb
index 14643e5c81..921ce738c5 100644
--- a/spec/plugins/source_spec.rb
+++ b/spec/plugins/source_spec.rb
@@ -21,7 +21,7 @@ RSpec.describe "bundler source plugin" do
end
G
- allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
+ allow(Bundler::SharedHelpers).to receive(:pwd).and_return(bundled_app)
plugin_should_be_installed("bundler-source-psource")
end
@@ -76,7 +76,7 @@ RSpec.describe "bundler source plugin" do
end
it "installs the explicit one" do
- allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
+ allow(Bundler::SharedHelpers).to receive(:pwd).and_return(bundled_app)
plugin_should_be_installed("another-psource")
end
@@ -102,7 +102,7 @@ RSpec.describe "bundler source plugin" do
end
it "installs the default one" do
- allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
+ allow(Bundler::SharedHelpers).to receive(:pwd).and_return(bundled_app)
plugin_should_be_installed("bundler-source-psource")
end
end