2018-11-02 19:07:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
RSpec.describe "bundle install with explicit source paths" do
|
2019-01-04 08:10:58 -05:00
|
|
|
it "fetches gems with a global path source", :bundler => "< 3" do
|
2018-11-02 19:07:56 -04:00
|
|
|
build_lib "foo"
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
|
|
|
path "#{lib_path("foo-1.0")}"
|
|
|
|
gem 'foo'
|
|
|
|
G
|
|
|
|
|
|
|
|
expect(the_bundle).to include_gems("foo 1.0")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "fetches gems" do
|
|
|
|
build_lib "foo"
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
|
|
|
path "#{lib_path("foo-1.0")}" do
|
|
|
|
gem 'foo'
|
|
|
|
end
|
|
|
|
G
|
|
|
|
|
|
|
|
expect(the_bundle).to include_gems("foo 1.0")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "supports pinned paths" do
|
|
|
|
build_lib "foo"
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
|
|
|
gem 'foo', :path => "#{lib_path("foo-1.0")}"
|
|
|
|
G
|
|
|
|
|
|
|
|
expect(the_bundle).to include_gems("foo 1.0")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "supports relative paths" do
|
|
|
|
build_lib "foo"
|
|
|
|
|
2020-05-08 01:19:04 -04:00
|
|
|
relative_path = lib_path("foo-1.0").relative_path_from(bundled_app)
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
install_gemfile <<-G
|
|
|
|
gem 'foo', :path => "#{relative_path}"
|
|
|
|
G
|
|
|
|
|
|
|
|
expect(the_bundle).to include_gems("foo 1.0")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "expands paths" do
|
|
|
|
build_lib "foo"
|
|
|
|
|
|
|
|
relative_path = lib_path("foo-1.0").relative_path_from(Pathname.new("~").expand_path)
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
|
|
|
gem 'foo', :path => "~/#{relative_path}"
|
|
|
|
G
|
|
|
|
|
|
|
|
expect(the_bundle).to include_gems("foo 1.0")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "expands paths raise error with not existing user's home dir" do
|
2020-05-08 01:19:04 -04:00
|
|
|
skip "problems with ~ expansion" if Gem.win_platform?
|
|
|
|
|
2018-11-02 19:07:56 -04:00
|
|
|
build_lib "foo"
|
|
|
|
username = "some_unexisting_user"
|
|
|
|
relative_path = lib_path("foo-1.0").relative_path_from(Pathname.new("/home/#{username}").expand_path)
|
|
|
|
|
2020-06-03 12:43:17 -04:00
|
|
|
install_gemfile <<-G, :raise_on_error => false
|
2018-11-02 19:07:56 -04:00
|
|
|
gem 'foo', :path => "~#{username}/#{relative_path}"
|
|
|
|
G
|
2019-04-14 02:01:35 -04:00
|
|
|
expect(err).to match("There was an error while trying to use the path `~#{username}/#{relative_path}`.")
|
|
|
|
expect(err).to match("user #{username} doesn't exist")
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "expands paths relative to Bundler.root" do
|
|
|
|
build_lib "foo", :path => bundled_app("foo-1.0")
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
|
|
|
gem 'foo', :path => "./foo-1.0"
|
|
|
|
G
|
|
|
|
|
2020-05-08 01:19:04 -04:00
|
|
|
expect(the_bundle).to include_gems("foo 1.0", :dir => bundled_app("subdir").mkpath)
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
2019-07-24 13:46:19 -04:00
|
|
|
it "sorts paths consistently on install and update when they start with ./" do
|
|
|
|
build_lib "demo", :path => lib_path("demo")
|
|
|
|
build_lib "aaa", :path => lib_path("demo/aaa")
|
|
|
|
|
|
|
|
gemfile = <<-G
|
|
|
|
gemspec
|
|
|
|
gem "aaa", :path => "./aaa"
|
|
|
|
G
|
|
|
|
|
|
|
|
File.open(lib_path("demo/Gemfile"), "w") {|f| f.puts gemfile }
|
|
|
|
|
|
|
|
lockfile = <<~L
|
|
|
|
PATH
|
|
|
|
remote: .
|
|
|
|
specs:
|
|
|
|
demo (1.0)
|
|
|
|
|
|
|
|
PATH
|
|
|
|
remote: aaa
|
|
|
|
specs:
|
|
|
|
aaa (1.0)
|
|
|
|
|
|
|
|
GEM
|
|
|
|
specs:
|
|
|
|
|
|
|
|
PLATFORMS
|
|
|
|
#{lockfile_platforms}
|
|
|
|
|
|
|
|
DEPENDENCIES
|
|
|
|
aaa!
|
|
|
|
demo!
|
|
|
|
|
|
|
|
BUNDLED WITH
|
|
|
|
#{Bundler::VERSION}
|
|
|
|
L
|
|
|
|
|
2020-05-08 01:19:04 -04:00
|
|
|
bundle :install, :dir => lib_path("demo")
|
|
|
|
expect(lib_path("demo/Gemfile.lock")).to have_lockfile(lockfile)
|
|
|
|
bundle :update, :all => true, :dir => lib_path("demo")
|
|
|
|
expect(lib_path("demo/Gemfile.lock")).to have_lockfile(lockfile)
|
2019-07-24 13:46:19 -04:00
|
|
|
end
|
|
|
|
|
2018-11-02 19:07:56 -04:00
|
|
|
it "expands paths when comparing locked paths to Gemfile paths" do
|
|
|
|
build_lib "foo", :path => bundled_app("foo-1.0")
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
|
|
|
gem 'foo', :path => File.expand_path("../foo-1.0", __FILE__)
|
|
|
|
G
|
|
|
|
|
2020-05-29 06:46:16 -04:00
|
|
|
bundle "config --local frozen true"
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "installs dependencies from the path even if a newer gem is available elsewhere" do
|
2020-05-08 01:19:04 -04:00
|
|
|
skip "override is not winning" if Gem.win_platform?
|
|
|
|
|
2018-11-02 19:07:56 -04:00
|
|
|
system_gems "rack-1.0.0"
|
|
|
|
|
|
|
|
build_lib "rack", "1.0", :path => lib_path("nested/bar") do |s|
|
|
|
|
s.write "lib/rack.rb", "puts 'WIN OVERRIDE'"
|
|
|
|
end
|
|
|
|
|
|
|
|
build_lib "foo", :path => lib_path("nested") do |s|
|
|
|
|
s.add_dependency "rack", "= 1.0"
|
|
|
|
end
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gem "foo", :path => "#{lib_path("nested")}"
|
|
|
|
G
|
|
|
|
|
|
|
|
run "require 'rack'"
|
|
|
|
expect(out).to eq("WIN OVERRIDE")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "works" do
|
|
|
|
build_gem "foo", "1.0.0", :to_system => true do |s|
|
|
|
|
s.write "lib/foo.rb", "puts 'FAIL'"
|
|
|
|
end
|
|
|
|
|
|
|
|
build_lib "omg", "1.0", :path => lib_path("omg") do |s|
|
|
|
|
s.add_dependency "foo"
|
|
|
|
end
|
|
|
|
|
|
|
|
build_lib "foo", "1.0.0", :path => lib_path("omg/foo")
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
|
|
|
gem "omg", :path => "#{lib_path("omg")}"
|
|
|
|
G
|
|
|
|
|
|
|
|
expect(the_bundle).to include_gems "foo 1.0"
|
|
|
|
end
|
|
|
|
|
2019-04-14 02:01:35 -04:00
|
|
|
it "works with only_update_to_newer_versions" do
|
|
|
|
build_lib "omg", "2.0", :path => lib_path("omg")
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
|
|
|
gem "omg", :path => "#{lib_path("omg")}"
|
|
|
|
G
|
|
|
|
|
|
|
|
build_lib "omg", "1.0", :path => lib_path("omg")
|
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install, :env => { "BUNDLE_BUNDLE_ONLY_UPDATE_TO_NEWER_VERSIONS" => "true" }
|
2019-04-14 02:01:35 -04:00
|
|
|
|
|
|
|
expect(the_bundle).to include_gems "omg 1.0"
|
|
|
|
end
|
|
|
|
|
2018-11-02 19:07:56 -04:00
|
|
|
it "prefers gemspecs closer to the path root" do
|
|
|
|
build_lib "premailer", "1.0.0", :path => lib_path("premailer") do |s|
|
|
|
|
s.write "gemfiles/ruby187.gemspec", <<-G
|
|
|
|
Gem::Specification.new do |s|
|
|
|
|
s.name = 'premailer'
|
|
|
|
s.version = '1.0.0'
|
|
|
|
s.summary = 'Hi'
|
|
|
|
s.authors = 'Me'
|
|
|
|
end
|
|
|
|
G
|
|
|
|
end
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
|
|
|
gem "premailer", :path => "#{lib_path("premailer")}"
|
|
|
|
G
|
|
|
|
|
|
|
|
# Installation of the 'gemfiles' gemspec would fail since it will be unable
|
|
|
|
# to require 'premailer.rb'
|
|
|
|
expect(the_bundle).to include_gems "premailer 1.0.0"
|
|
|
|
end
|
|
|
|
|
2019-04-14 02:01:35 -04:00
|
|
|
it "warns on invalid specs" do
|
2018-11-02 19:07:56 -04:00
|
|
|
build_lib "foo"
|
|
|
|
|
|
|
|
gemspec = lib_path("foo-1.0").join("foo.gemspec").to_s
|
|
|
|
File.open(gemspec, "w") do |f|
|
|
|
|
f.write <<-G
|
|
|
|
Gem::Specification.new do |s|
|
|
|
|
s.name = "foo"
|
|
|
|
end
|
|
|
|
G
|
|
|
|
end
|
|
|
|
|
2020-06-03 12:43:17 -04:00
|
|
|
install_gemfile <<-G, :raise_on_error => false
|
2018-11-02 19:07:56 -04:00
|
|
|
gem "foo", :path => "#{lib_path("foo-1.0")}"
|
|
|
|
G
|
|
|
|
|
2019-04-14 02:01:35 -04:00
|
|
|
expect(err).to_not include("Your Gemfile has no gem server sources.")
|
|
|
|
expect(err).to match(/is not valid. Please fix this gemspec./)
|
|
|
|
expect(err).to match(/The validation error was 'missing value for attribute version'/)
|
|
|
|
expect(err).to match(/You have one or more invalid gemspecs that need to be fixed/)
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "supports gemspec syntax" do
|
|
|
|
build_lib "foo", "1.0", :path => lib_path("foo") do |s|
|
|
|
|
s.add_dependency "rack", "1.0"
|
|
|
|
end
|
|
|
|
|
|
|
|
gemfile = <<-G
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gemspec
|
|
|
|
G
|
|
|
|
|
|
|
|
File.open(lib_path("foo/Gemfile"), "w") {|f| f.puts gemfile }
|
|
|
|
|
2020-05-08 01:19:04 -04:00
|
|
|
bundle "install", :dir => lib_path("foo")
|
|
|
|
expect(the_bundle).to include_gems "foo 1.0", :dir => lib_path("foo")
|
|
|
|
expect(the_bundle).to include_gems "rack 1.0", :dir => lib_path("foo")
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "supports gemspec syntax with an alternative path" do
|
|
|
|
build_lib "foo", "1.0", :path => lib_path("foo") do |s|
|
|
|
|
s.add_dependency "rack", "1.0"
|
|
|
|
end
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gemspec :path => "#{lib_path("foo")}"
|
|
|
|
G
|
|
|
|
|
|
|
|
expect(the_bundle).to include_gems "foo 1.0"
|
|
|
|
expect(the_bundle).to include_gems "rack 1.0"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't automatically unlock dependencies when using the gemspec syntax" do
|
|
|
|
build_lib "foo", "1.0", :path => lib_path("foo") do |s|
|
|
|
|
s.add_dependency "rack", ">= 1.0"
|
|
|
|
end
|
|
|
|
|
2020-05-08 01:19:04 -04:00
|
|
|
install_gemfile lib_path("foo/Gemfile"), <<-G, :dir => lib_path("foo")
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gemspec
|
|
|
|
G
|
|
|
|
|
|
|
|
build_gem "rack", "1.0.1", :to_system => true
|
|
|
|
|
2020-05-08 01:19:04 -04:00
|
|
|
bundle "install", :dir => lib_path("foo")
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2020-05-08 01:19:04 -04:00
|
|
|
expect(the_bundle).to include_gems "foo 1.0", :dir => lib_path("foo")
|
|
|
|
expect(the_bundle).to include_gems "rack 1.0", :dir => lib_path("foo")
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't automatically unlock dependencies when using the gemspec syntax and the gem has development dependencies" do
|
|
|
|
build_lib "foo", "1.0", :path => lib_path("foo") do |s|
|
|
|
|
s.add_dependency "rack", ">= 1.0"
|
|
|
|
s.add_development_dependency "activesupport"
|
|
|
|
end
|
|
|
|
|
2020-05-08 01:19:04 -04:00
|
|
|
install_gemfile lib_path("foo/Gemfile"), <<-G, :dir => lib_path("foo")
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gemspec
|
|
|
|
G
|
|
|
|
|
|
|
|
build_gem "rack", "1.0.1", :to_system => true
|
|
|
|
|
2020-05-08 01:19:04 -04:00
|
|
|
bundle "install", :dir => lib_path("foo")
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2020-05-08 01:19:04 -04:00
|
|
|
expect(the_bundle).to include_gems "foo 1.0", :dir => lib_path("foo")
|
|
|
|
expect(the_bundle).to include_gems "rack 1.0", :dir => lib_path("foo")
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "raises if there are multiple gemspecs" do
|
|
|
|
build_lib "foo", "1.0", :path => lib_path("foo") do |s|
|
|
|
|
s.write "bar.gemspec", build_spec("bar", "1.0").first.to_ruby
|
|
|
|
end
|
|
|
|
|
2020-06-03 12:43:17 -04:00
|
|
|
install_gemfile <<-G, :raise_on_error => false
|
2018-11-02 19:07:56 -04:00
|
|
|
gemspec :path => "#{lib_path("foo")}"
|
|
|
|
G
|
|
|
|
|
|
|
|
expect(exitstatus).to eq(15) if exitstatus
|
2019-04-14 02:01:35 -04:00
|
|
|
expect(err).to match(/There are multiple gemspecs/)
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "allows :name to be specified to resolve ambiguity" do
|
|
|
|
build_lib "foo", "1.0", :path => lib_path("foo") do |s|
|
|
|
|
s.write "bar.gemspec"
|
|
|
|
end
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
|
|
|
gemspec :path => "#{lib_path("foo")}", :name => "foo"
|
|
|
|
G
|
|
|
|
|
|
|
|
expect(the_bundle).to include_gems "foo 1.0"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "sets up executables" do
|
|
|
|
build_lib "foo" do |s|
|
|
|
|
s.executables = "foobar"
|
|
|
|
end
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
|
|
|
path "#{lib_path("foo-1.0")}" do
|
|
|
|
gem 'foo'
|
|
|
|
end
|
|
|
|
G
|
|
|
|
expect(the_bundle).to include_gems "foo 1.0"
|
|
|
|
|
|
|
|
bundle "exec foobar"
|
|
|
|
expect(out).to eq("1.0")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "handles directories in bin/" do
|
|
|
|
build_lib "foo"
|
|
|
|
lib_path("foo-1.0").join("foo.gemspec").rmtree
|
|
|
|
lib_path("foo-1.0").join("bin/performance").mkpath
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
|
|
|
gem 'foo', '1.0', :path => "#{lib_path("foo-1.0")}"
|
|
|
|
G
|
2019-06-01 05:49:40 -04:00
|
|
|
expect(err).to be_empty
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "removes the .gem file after installing" do
|
|
|
|
build_lib "foo"
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
|
|
|
gem 'foo', :path => "#{lib_path("foo-1.0")}"
|
|
|
|
G
|
|
|
|
|
|
|
|
expect(lib_path("foo-1.0").join("foo-1.0.gem")).not_to exist
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "block syntax" do
|
|
|
|
it "pulls all gems from a path block" do
|
|
|
|
build_lib "omg"
|
|
|
|
build_lib "hi2u"
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
|
|
|
path "#{lib_path}" do
|
|
|
|
gem "omg"
|
|
|
|
gem "hi2u"
|
|
|
|
end
|
|
|
|
G
|
|
|
|
|
|
|
|
expect(the_bundle).to include_gems "omg 1.0", "hi2u 1.0"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "keeps source pinning" do
|
|
|
|
build_lib "foo", "1.0", :path => lib_path("foo")
|
|
|
|
build_lib "omg", "1.0", :path => lib_path("omg")
|
|
|
|
build_lib "foo", "1.0", :path => lib_path("omg/foo") do |s|
|
|
|
|
s.write "lib/foo.rb", "puts 'FAIL'"
|
|
|
|
end
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
|
|
|
gem "foo", :path => "#{lib_path("foo")}"
|
|
|
|
gem "omg", :path => "#{lib_path("omg")}"
|
|
|
|
G
|
|
|
|
|
|
|
|
expect(the_bundle).to include_gems "foo 1.0"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "works when the path does not have a gemspec" do
|
|
|
|
build_lib "foo", :gemspec => false
|
|
|
|
|
|
|
|
gemfile <<-G
|
|
|
|
gem "foo", "1.0", :path => "#{lib_path("foo-1.0")}"
|
|
|
|
G
|
|
|
|
|
|
|
|
expect(the_bundle).to include_gems "foo 1.0"
|
|
|
|
|
|
|
|
expect(the_bundle).to include_gems "foo 1.0"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "works when the path does not have a gemspec but there is a lockfile" do
|
2019-07-24 13:48:10 -04:00
|
|
|
lockfile <<~L
|
|
|
|
PATH
|
|
|
|
remote: vendor/bar
|
|
|
|
specs:
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-07-24 13:48:10 -04:00
|
|
|
GEM
|
|
|
|
remote: http://rubygems.org
|
2018-11-02 19:07:56 -04:00
|
|
|
L
|
|
|
|
|
2020-05-08 01:19:04 -04:00
|
|
|
FileUtils.mkdir_p(bundled_app("vendor/bar"))
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
install_gemfile <<-G
|
|
|
|
gem "bar", "1.0.0", path: "vendor/bar", require: "bar/nyard"
|
|
|
|
G
|
|
|
|
end
|
|
|
|
|
|
|
|
context "existing lockfile" do
|
|
|
|
it "rubygems gems don't re-resolve without changes" do
|
|
|
|
install_gemfile <<-G
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gem 'rack-obama', '1.0'
|
|
|
|
gem 'net-ssh', '1.0'
|
|
|
|
G
|
|
|
|
|
2019-12-14 05:49:16 -05:00
|
|
|
bundle :check, :env => { "DEBUG" => "1" }
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to match(/using resolution from the lockfile/)
|
|
|
|
expect(the_bundle).to include_gems "rack-obama 1.0", "net-ssh 1.0"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "source path gems w/deps don't re-resolve without changes" do
|
|
|
|
build_lib "rack-obama", "1.0", :path => lib_path("omg") do |s|
|
|
|
|
s.add_dependency "yard"
|
|
|
|
end
|
|
|
|
|
|
|
|
build_lib "net-ssh", "1.0", :path => lib_path("omg") do |s|
|
|
|
|
s.add_dependency "yard"
|
|
|
|
end
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gem 'rack-obama', :path => "#{lib_path("omg")}"
|
|
|
|
gem 'net-ssh', :path => "#{lib_path("omg")}"
|
|
|
|
G
|
|
|
|
|
2019-12-14 05:49:16 -05:00
|
|
|
bundle :check, :env => { "DEBUG" => "1" }
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to match(/using resolution from the lockfile/)
|
|
|
|
expect(the_bundle).to include_gems "rack-obama 1.0", "net-ssh 1.0"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "installs executable stubs" do
|
|
|
|
build_lib "foo" do |s|
|
|
|
|
s.executables = ["foo"]
|
|
|
|
end
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
|
|
|
gem "foo", :path => "#{lib_path("foo-1.0")}"
|
|
|
|
G
|
|
|
|
|
|
|
|
bundle "exec foo"
|
|
|
|
expect(out).to eq("1.0")
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "when the gem version in the path is updated" do
|
|
|
|
before :each do
|
|
|
|
build_lib "foo", "1.0", :path => lib_path("foo") do |s|
|
|
|
|
s.add_dependency "bar"
|
|
|
|
end
|
|
|
|
build_lib "bar", "1.0", :path => lib_path("foo/bar")
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
|
|
|
gem "foo", :path => "#{lib_path("foo")}"
|
|
|
|
G
|
|
|
|
end
|
|
|
|
|
|
|
|
it "unlocks all gems when the top level gem is updated" do
|
|
|
|
build_lib "foo", "2.0", :path => lib_path("foo") do |s|
|
|
|
|
s.add_dependency "bar"
|
|
|
|
end
|
|
|
|
|
|
|
|
bundle "install"
|
|
|
|
|
|
|
|
expect(the_bundle).to include_gems "foo 2.0", "bar 1.0"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "unlocks all gems when a child dependency gem is updated" do
|
|
|
|
build_lib "bar", "2.0", :path => lib_path("foo/bar")
|
|
|
|
|
|
|
|
bundle "install"
|
|
|
|
|
|
|
|
expect(the_bundle).to include_gems "foo 1.0", "bar 2.0"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "when dependencies in the path are updated" do
|
|
|
|
before :each do
|
|
|
|
build_lib "foo", "1.0", :path => lib_path("foo")
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gem "foo", :path => "#{lib_path("foo")}"
|
|
|
|
G
|
|
|
|
end
|
|
|
|
|
|
|
|
it "gets dependencies that are updated in the path" do
|
|
|
|
build_lib "foo", "1.0", :path => lib_path("foo") do |s|
|
|
|
|
s.add_dependency "rack"
|
|
|
|
end
|
|
|
|
|
|
|
|
bundle "install"
|
|
|
|
|
|
|
|
expect(the_bundle).to include_gems "rack 1.0.0"
|
|
|
|
end
|
2019-06-01 05:49:40 -04:00
|
|
|
|
|
|
|
it "keeps using the same version if it's compatible" do
|
|
|
|
build_lib "foo", "1.0", :path => lib_path("foo") do |s|
|
|
|
|
s.add_dependency "rack", "0.9.1"
|
|
|
|
end
|
|
|
|
|
|
|
|
bundle "install"
|
|
|
|
|
|
|
|
expect(the_bundle).to include_gems "rack 0.9.1"
|
|
|
|
|
|
|
|
lockfile_should_be <<-G
|
|
|
|
PATH
|
|
|
|
remote: #{lib_path("foo")}
|
|
|
|
specs:
|
|
|
|
foo (1.0)
|
|
|
|
rack (= 0.9.1)
|
|
|
|
|
|
|
|
GEM
|
2019-05-06 12:06:21 -04:00
|
|
|
remote: #{file_uri_for(gem_repo1)}/
|
2019-06-01 05:49:40 -04:00
|
|
|
specs:
|
|
|
|
rack (0.9.1)
|
|
|
|
|
|
|
|
PLATFORMS
|
|
|
|
#{lockfile_platforms}
|
|
|
|
|
|
|
|
DEPENDENCIES
|
|
|
|
foo!
|
|
|
|
|
|
|
|
BUNDLED WITH
|
|
|
|
#{Bundler::VERSION}
|
|
|
|
G
|
|
|
|
|
|
|
|
build_lib "foo", "1.0", :path => lib_path("foo") do |s|
|
|
|
|
s.add_dependency "rack"
|
|
|
|
end
|
|
|
|
|
|
|
|
bundle "install"
|
|
|
|
|
|
|
|
lockfile_should_be <<-G
|
|
|
|
PATH
|
|
|
|
remote: #{lib_path("foo")}
|
|
|
|
specs:
|
|
|
|
foo (1.0)
|
|
|
|
rack
|
|
|
|
|
|
|
|
GEM
|
2019-05-06 12:06:21 -04:00
|
|
|
remote: #{file_uri_for(gem_repo1)}/
|
2019-06-01 05:49:40 -04:00
|
|
|
specs:
|
|
|
|
rack (0.9.1)
|
|
|
|
|
|
|
|
PLATFORMS
|
|
|
|
#{lockfile_platforms}
|
|
|
|
|
|
|
|
DEPENDENCIES
|
|
|
|
foo!
|
|
|
|
|
|
|
|
BUNDLED WITH
|
|
|
|
#{Bundler::VERSION}
|
|
|
|
G
|
|
|
|
|
|
|
|
expect(the_bundle).to include_gems "rack 0.9.1"
|
|
|
|
end
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "switching sources" do
|
|
|
|
it "doesn't switch pinned git sources to rubygems when pinning the parent gem to a path source" do
|
|
|
|
build_gem "foo", "1.0", :to_system => true do |s|
|
|
|
|
s.write "lib/foo.rb", "raise 'fail'"
|
|
|
|
end
|
|
|
|
build_lib "foo", "1.0", :path => lib_path("bar/foo")
|
|
|
|
build_git "bar", "1.0", :path => lib_path("bar") do |s|
|
|
|
|
s.add_dependency "foo"
|
|
|
|
end
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gem "bar", :git => "#{lib_path("bar")}"
|
|
|
|
G
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gem "bar", :path => "#{lib_path("bar")}"
|
|
|
|
G
|
|
|
|
|
|
|
|
expect(the_bundle).to include_gems "foo 1.0", "bar 1.0"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "switches the source when the gem existed in rubygems and the path was already being used for another gem" do
|
|
|
|
build_lib "foo", "1.0", :path => lib_path("foo")
|
2020-06-07 09:28:16 -04:00
|
|
|
build_gem "bar", "1.0", :to_bundle => true do |s|
|
2018-11-02 19:07:56 -04:00
|
|
|
s.write "lib/bar.rb", "raise 'fail'"
|
|
|
|
end
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gem "bar"
|
|
|
|
path "#{lib_path("foo")}" do
|
|
|
|
gem "foo"
|
|
|
|
end
|
|
|
|
G
|
|
|
|
|
|
|
|
build_lib "bar", "1.0", :path => lib_path("foo/bar")
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
path "#{lib_path("foo")}" do
|
|
|
|
gem "foo"
|
|
|
|
gem "bar"
|
|
|
|
end
|
|
|
|
G
|
|
|
|
|
|
|
|
expect(the_bundle).to include_gems "bar 1.0"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "when there are both a gemspec and remote gems" do
|
|
|
|
it "doesn't query rubygems for local gemspec name" do
|
2020-05-08 01:19:04 -04:00
|
|
|
skip "platform issues" if Gem.win_platform?
|
|
|
|
|
2018-11-02 19:07:56 -04:00
|
|
|
build_lib "private_lib", "2.2", :path => lib_path("private_lib")
|
|
|
|
gemfile = <<-G
|
|
|
|
source "http://localgemserver.test"
|
|
|
|
gemspec
|
|
|
|
gem 'rack'
|
|
|
|
G
|
|
|
|
File.open(lib_path("private_lib/Gemfile"), "w") {|f| f.puts gemfile }
|
|
|
|
|
2020-05-08 01:19:04 -04:00
|
|
|
bundle :install, :env => { "DEBUG" => "1" }, :artifice => "endpoint", :dir => lib_path("private_lib")
|
|
|
|
expect(out).to match(%r{^HTTP GET http://localgemserver\.test/api/v1/dependencies\?gems=rack$})
|
|
|
|
expect(out).not_to match(/^HTTP GET.*private_lib/)
|
|
|
|
expect(the_bundle).to include_gems "private_lib 2.2", :dir => lib_path("private_lib")
|
|
|
|
expect(the_bundle).to include_gems "rack 1.0", :dir => lib_path("private_lib")
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "gem install hooks" do
|
|
|
|
it "runs pre-install hooks" do
|
|
|
|
build_git "foo"
|
|
|
|
gemfile <<-G
|
|
|
|
gem "foo", :git => "#{lib_path("foo-1.0")}"
|
|
|
|
G
|
|
|
|
|
|
|
|
File.open(lib_path("install_hooks.rb"), "w") do |h|
|
|
|
|
h.write <<-H
|
|
|
|
Gem.pre_install_hooks << lambda do |inst|
|
|
|
|
STDERR.puts "Ran pre-install hook: \#{inst.spec.full_name}"
|
|
|
|
end
|
|
|
|
H
|
|
|
|
end
|
|
|
|
|
|
|
|
bundle :install,
|
|
|
|
:requires => [lib_path("install_hooks.rb")]
|
2019-04-14 02:01:35 -04:00
|
|
|
expect(err_without_deprecations).to eq("Ran pre-install hook: foo-1.0")
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "runs post-install hooks" do
|
|
|
|
build_git "foo"
|
|
|
|
gemfile <<-G
|
|
|
|
gem "foo", :git => "#{lib_path("foo-1.0")}"
|
|
|
|
G
|
|
|
|
|
|
|
|
File.open(lib_path("install_hooks.rb"), "w") do |h|
|
|
|
|
h.write <<-H
|
|
|
|
Gem.post_install_hooks << lambda do |inst|
|
|
|
|
STDERR.puts "Ran post-install hook: \#{inst.spec.full_name}"
|
|
|
|
end
|
|
|
|
H
|
|
|
|
end
|
|
|
|
|
|
|
|
bundle :install,
|
|
|
|
:requires => [lib_path("install_hooks.rb")]
|
2019-04-14 02:01:35 -04:00
|
|
|
expect(err_without_deprecations).to eq("Ran post-install hook: foo-1.0")
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "complains if the install hook fails" do
|
|
|
|
build_git "foo"
|
|
|
|
gemfile <<-G
|
|
|
|
gem "foo", :git => "#{lib_path("foo-1.0")}"
|
|
|
|
G
|
|
|
|
|
|
|
|
File.open(lib_path("install_hooks.rb"), "w") do |h|
|
|
|
|
h.write <<-H
|
|
|
|
Gem.pre_install_hooks << lambda do |inst|
|
|
|
|
false
|
|
|
|
end
|
|
|
|
H
|
|
|
|
end
|
|
|
|
|
2020-06-03 12:43:17 -04:00
|
|
|
bundle :install, :requires => [lib_path("install_hooks.rb")], :raise_on_error => false
|
2019-04-14 02:01:35 -04:00
|
|
|
expect(err).to include("failed for foo-1.0")
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "loads plugins from the path gem" do
|
|
|
|
foo_file = home("foo_plugin_loaded")
|
|
|
|
bar_file = home("bar_plugin_loaded")
|
|
|
|
expect(foo_file).not_to be_file
|
|
|
|
expect(bar_file).not_to be_file
|
|
|
|
|
|
|
|
build_lib "foo" do |s|
|
|
|
|
s.write("lib/rubygems_plugin.rb", "FileUtils.touch('#{foo_file}')")
|
|
|
|
end
|
|
|
|
|
|
|
|
build_git "bar" do |s|
|
|
|
|
s.write("lib/rubygems_plugin.rb", "FileUtils.touch('#{bar_file}')")
|
|
|
|
end
|
|
|
|
|
2020-06-03 14:46:03 -04:00
|
|
|
install_gemfile <<-G
|
2018-11-02 19:07:56 -04:00
|
|
|
gem "foo", :path => "#{lib_path("foo-1.0")}"
|
|
|
|
gem "bar", :path => "#{lib_path("bar-1.0")}"
|
|
|
|
G
|
|
|
|
|
|
|
|
expect(foo_file).to be_file
|
|
|
|
expect(bar_file).to be_file
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|