Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Update specs for path always including ruby scope
Browse files Browse the repository at this point in the history
  • Loading branch information
segiddins committed Jul 22, 2018
1 parent 15bb64a commit 92fe3ba
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 30 deletions.
2 changes: 1 addition & 1 deletion lib/bundler/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def pretty_values_for(exposed_key)
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)
Expand Down
96 changes: 67 additions & 29 deletions spec/install/path_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,44 +103,82 @@ def set_bundle_path(type, location)
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

Expand Down Expand Up @@ -201,7 +239,7 @@ def set_bundle_path(type, location)
describe "to a file" do
before do
in_app_root do
`touch /tmp/idontexist bundle`
FileUtils.touch "bundle"
end
end

Expand All @@ -212,7 +250,7 @@ def set_bundle_path(type, location)
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

0 comments on commit 92fe3ba

Please sign in to comment.