summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2018-07-21 22:28:26 -0700
committerSamuel Giddins <segiddins@segiddins.me>2018-07-21 22:28:52 -0700
commit92fe3ba13d3164a6b2f3e5d2d7dc8b8fbe9aaa46 (patch)
treec1c9f040e3f7feda8d691978525b8289a86f4ae1
parent15bb64af9b3ca45afdbbc088efa0034c8d83f76e (diff)
downloadbundler-segiddins/bundler-2-global-path-ruby-scope.tar.gz
Update specs for path always including ruby scopesegiddins/bundler-2-global-path-ruby-scope
-rw-r--r--lib/bundler/settings.rb2
-rw-r--r--spec/install/path_spec.rb96
2 files changed, 68 insertions, 30 deletions
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index e37bfb442a..fe68d510ff 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -220,7 +220,7 @@ module Bundler
locations
end
- # for legacy reasons, the ruby scope isnt appended when the setting comes from ENV or the global config,
+ # for legacy reasons, in Bundler 1, the ruby scope isnt appended when the setting comes from ENV or the global config,
# nor do we respect :disable_shared_gems
def path
key = key_for(:path)
diff --git a/spec/install/path_spec.rb b/spec/install/path_spec.rb
index 3ed2b30cce..5f3fedb862 100644
--- a/spec/install/path_spec.rb
+++ b/spec/install/path_spec.rb
@@ -103,44 +103,82 @@ RSpec.describe "bundle install" do
end
[:env, :global].each do |type|
- it "installs gems to a path if one is specified" do
- set_bundle_path(type, bundled_app("vendor2").to_s)
- bundle! :install, forgotten_command_line_options(:path => "vendor/bundle")
+ context "when set via #{type}" do
+ it "installs gems to a path if one is specified" do
+ set_bundle_path(type, bundled_app("vendor2").to_s)
+ bundle! :install, forgotten_command_line_options(:path => "vendor/bundle")
+
+ expect(vendored_gems("gems/rack-1.0.0")).to be_directory
+ expect(bundled_app("vendor2")).not_to be_directory
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ end
- expect(vendored_gems("gems/rack-1.0.0")).to be_directory
- expect(bundled_app("vendor2")).not_to be_directory
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
+ context "with global_path_appends_ruby_scope set", :bundler => "2" do
+ it "installs gems to ." do
+ set_bundle_path(type, ".")
+ bundle! "config --global disable_shared_gems true"
- it "installs gems to ." do
- set_bundle_path(type, ".")
- bundle! "config --global disable_shared_gems true"
+ bundle! :install
- bundle! :install
+ paths_to_exist = %w[cache/rack-1.0.0.gem gems/rack-1.0.0 specifications/rack-1.0.0.gemspec].map {|path| bundled_app(Bundler.ruby_scope, path) }
+ expect(paths_to_exist).to all exist
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ end
- expect([bundled_app("cache/rack-1.0.0.gem"), bundled_app("gems/rack-1.0.0"), bundled_app("specifications/rack-1.0.0.gemspec")]).to all exist
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
+ it "installs gems to the path" do
+ set_bundle_path(type, bundled_app("vendor").to_s)
- it "installs gems to BUNDLE_PATH with #{type}" do
- set_bundle_path(type, bundled_app("vendor").to_s)
+ bundle! :install
- bundle :install
+ expect(bundled_app("vendor", Bundler.ruby_scope, "gems/rack-1.0.0")).to be_directory
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ end
- expect(bundled_app("vendor/gems/rack-1.0.0")).to be_directory
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
+ it "installs gems to the path relative to root when relative" do
+ set_bundle_path(type, "vendor")
- it "installs gems to BUNDLE_PATH relative to root when relative" do
- set_bundle_path(type, "vendor")
+ FileUtils.mkdir_p bundled_app("lol")
+ Dir.chdir(bundled_app("lol")) do
+ bundle! :install
+ end
- FileUtils.mkdir_p bundled_app("lol")
- Dir.chdir(bundled_app("lol")) do
- bundle :install
+ expect(bundled_app("vendor", Bundler.ruby_scope, "gems/rack-1.0.0")).to be_directory
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ end
end
- expect(bundled_app("vendor/gems/rack-1.0.0")).to be_directory
- expect(the_bundle).to include_gems "rack 1.0.0"
+ context "with global_path_appends_ruby_scope unset", :bundler => "< 2" do
+ it "installs gems to ." do
+ set_bundle_path(type, ".")
+ bundle! "config --global disable_shared_gems true"
+
+ bundle! :install
+
+ expect([bundled_app("cache/rack-1.0.0.gem"), bundled_app("gems/rack-1.0.0"), bundled_app("specifications/rack-1.0.0.gemspec")]).to all exist
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ end
+
+ it "installs gems to BUNDLE_PATH with #{type}" do
+ set_bundle_path(type, bundled_app("vendor").to_s)
+
+ bundle :install
+
+ expect(bundled_app("vendor/gems/rack-1.0.0")).to be_directory
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ end
+
+ it "installs gems to BUNDLE_PATH relative to root when relative" do
+ set_bundle_path(type, "vendor")
+
+ FileUtils.mkdir_p bundled_app("lol")
+ Dir.chdir(bundled_app("lol")) do
+ bundle :install
+ end
+
+ expect(bundled_app("vendor/gems/rack-1.0.0")).to be_directory
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ end
+ end
end
end
@@ -201,7 +239,7 @@ RSpec.describe "bundle install" do
describe "to a file" do
before do
in_app_root do
- `touch /tmp/idontexist bundle`
+ FileUtils.touch "bundle"
end
end
@@ -212,7 +250,7 @@ RSpec.describe "bundle install" do
G
bundle :install, forgotten_command_line_options(:path => "bundle")
- expect(out).to match(/file already exists/)
+ expect(out).to include("file already exists")
end
end
end