diff --git a/bundler/spec/cache/gems_spec.rb b/bundler/spec/cache/gems_spec.rb index 2b5ba733f073..161ec64218c4 100644 --- a/bundler/spec/cache/gems_spec.rb +++ b/bundler/spec/cache/gems_spec.rb @@ -197,7 +197,12 @@ end it "adds and removes when gems are updated" do - update_repo2 + update_repo2 do + build_gem "rack", "1.2" do |s| + s.executables = "rackup" + end + end + bundle "update", :all => true expect(cached_gem("rack-1.2")).to exist expect(cached_gem("rack-1.0.0")).not_to exist diff --git a/bundler/spec/commands/binstubs_spec.rb b/bundler/spec/commands/binstubs_spec.rb index de381e92334f..e0296b2002a6 100644 --- a/bundler/spec/commands/binstubs_spec.rb +++ b/bundler/spec/commands/binstubs_spec.rb @@ -96,6 +96,10 @@ before do pristine_system_gems "bundler-#{system_bundler_version}" build_repo2 do + build_gem "rack", "1.2" do |s| + s.executables = "rackup" + end + build_gem "prints_loaded_gems", "1.0" do |s| s.executables = "print_loaded_gems" s.bindir = "exe" @@ -417,8 +421,14 @@ end it "works if the gem has development dependencies" do + build_repo2 do + build_gem "with_development_dependency" do |s| + s.add_development_dependency "activesupport", "= 2.3.5" + end + end + install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "with_development_dependency" G diff --git a/bundler/spec/commands/check_spec.rb b/bundler/spec/commands/check_spec.rb index dd691726771f..5a746591b3cd 100644 --- a/bundler/spec/commands/check_spec.rb +++ b/bundler/spec/commands/check_spec.rb @@ -71,13 +71,19 @@ end it "prints a generic message if you changed your lockfile" do + build_repo2 do + build_gem "rails_pinned_to_old_activesupport" do |s| + s.add_dependency "activesupport", "= 1.2.3" + end + end + install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem 'rails' G gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "rails" gem "rails_pinned_to_old_activesupport" G diff --git a/bundler/spec/commands/clean_spec.rb b/bundler/spec/commands/clean_spec.rb index bd8e7f16c76a..bb28e93902ed 100644 --- a/bundler/spec/commands/clean_spec.rb +++ b/bundler/spec/commands/clean_spec.rb @@ -603,8 +603,7 @@ def should_not_have_gems(*gems) it "when using --force on system gems, it doesn't remove binaries" do bundle "config set path.system true" - build_repo2 - update_repo2 do + build_repo2 do build_gem "bindir" do |s| s.bindir = "exe" s.executables = "foo" diff --git a/bundler/spec/commands/console_spec.rb b/bundler/spec/commands/console_spec.rb index 3092184f458e..6f1e96261efb 100644 --- a/bundler/spec/commands/console_spec.rb +++ b/bundler/spec/commands/console_spec.rb @@ -2,8 +2,43 @@ RSpec.describe "bundle console", :bundler => "< 3", :readline => true do before :each do + build_repo2 do + # A minimal fake pry console + build_gem "pry" do |s| + s.write "lib/pry.rb", <<-RUBY + class Pry + class << self + def toplevel_binding + unless defined?(@toplevel_binding) && @toplevel_binding + TOPLEVEL_BINDING.eval %{ + def self.__pry__; binding; end + Pry.instance_variable_set(:@toplevel_binding, __pry__) + class << self; undef __pry__; end + } + end + @toplevel_binding.eval('private') + @toplevel_binding + end + + def __pry__ + while line = gets + begin + puts eval(line, toplevel_binding).inspect.sub(/^"(.*)"$/, '=> \\1') + rescue Exception => e + puts "\#{e.class}: \#{e.message}" + puts e.backtrace.first + end + end + end + alias start __pry__ + end + end + RUBY + end + end + install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "rack" gem "activesupport", :group => :test gem "rack_middleware", :group => :development @@ -28,7 +63,7 @@ it "starts another REPL if configured as such" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "pry" G bundle "config set console pry" @@ -87,7 +122,7 @@ it "performs an automatic bundle install" do gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "rack" gem "activesupport", :group => :test gem "rack_middleware", :group => :development diff --git a/bundler/spec/commands/exec_spec.rb b/bundler/spec/commands/exec_spec.rb index 8b32e272c49b..03adcb889a53 100644 --- a/bundler/spec/commands/exec_spec.rb +++ b/bundler/spec/commands/exec_spec.rb @@ -357,7 +357,7 @@ bundle "config set clean false" # want to keep the rackup binstub install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" - gem "with_license" + gem "foo" G [true, false].each do |l| bundle "config set disable_exec_load #{l}" diff --git a/bundler/spec/commands/fund_spec.rb b/bundler/spec/commands/fund_spec.rb index ee3aff3a29dc..5a0c5411dabc 100644 --- a/bundler/spec/commands/fund_spec.rb +++ b/bundler/spec/commands/fund_spec.rb @@ -1,24 +1,51 @@ # frozen_string_literal: true RSpec.describe "bundle fund" do + before do + build_repo2 do + build_gem "has_funding_and_other_metadata" do |s| + s.metadata = { + "bug_tracker_uri" => "https://example.com/user/bestgemever/issues", + "changelog_uri" => "https://example.com/user/bestgemever/CHANGELOG.md", + "documentation_uri" => "https://www.example.info/gems/bestgemever/0.0.1", + "homepage_uri" => "https://bestgemever.example.io", + "mailing_list_uri" => "https://groups.example.com/bestgemever", + "funding_uri" => "https://example.com/has_funding_and_other_metadata/funding", + "source_code_uri" => "https://example.com/user/bestgemever", + "wiki_uri" => "https://example.com/user/bestgemever/wiki", + } + end + + build_gem "has_funding", "1.2.3" do |s| + s.metadata = { + "funding_uri" => "https://example.com/has_funding/funding", + } + end + + build_gem "gem_with_dependent_funding", "1.0" do |s| + s.add_dependency "has_funding" + end + end + end + it "prints fund information for all gems in the bundle" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" - gem 'has_metadata' + source "#{file_uri_for(gem_repo2)}" + gem 'has_funding_and_other_metadata' gem 'has_funding' gem 'rack-obama' G bundle "fund" - expect(out).to include("* has_metadata (1.0)\n Funding: https://example.com/has_metadata/funding") + expect(out).to include("* has_funding_and_other_metadata (1.0)\n Funding: https://example.com/has_funding_and_other_metadata/funding") expect(out).to include("* has_funding (1.2.3)\n Funding: https://example.com/has_funding/funding") expect(out).to_not include("rack-obama") end it "does not consider fund information for gem dependencies" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem 'gem_with_dependent_funding' G @@ -30,7 +57,7 @@ it "prints message if none of the gems have fund information" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem 'rack-obama' G @@ -42,13 +69,13 @@ describe "with --group option" do it "prints fund message for only specified group gems" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" - gem 'has_metadata', :group => :development + source "#{file_uri_for(gem_repo2)}" + gem 'has_funding_and_other_metadata', :group => :development gem 'has_funding' G bundle "fund --group development" - expect(out).to include("* has_metadata (1.0)\n Funding: https://example.com/has_metadata/funding") + expect(out).to include("* has_funding_and_other_metadata (1.0)\n Funding: https://example.com/has_funding_and_other_metadata/funding") expect(out).to_not include("* has_funding (1.2.3)\n Funding: https://example.com/has_funding/funding") end end diff --git a/bundler/spec/commands/info_spec.rb b/bundler/spec/commands/info_spec.rb index eec9c773bcf2..6bc07ea399ca 100644 --- a/bundler/spec/commands/info_spec.rb +++ b/bundler/spec/commands/info_spec.rb @@ -3,8 +3,22 @@ RSpec.describe "bundle info" do context "with a standard Gemfile" do before do + build_repo2 do + build_gem "has_metadata" do |s| + s.metadata = { + "bug_tracker_uri" => "https://example.com/user/bestgemever/issues", + "changelog_uri" => "https://example.com/user/bestgemever/CHANGELOG.md", + "documentation_uri" => "https://www.example.info/gems/bestgemever/0.0.1", + "homepage_uri" => "https://bestgemever.example.io", + "mailing_list_uri" => "https://groups.example.com/bestgemever", + "source_code_uri" => "https://example.com/user/bestgemever", + "wiki_uri" => "https://example.com/user/bestgemever/wiki", + } + end + end + install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "rails" gem "has_metadata" G @@ -66,7 +80,6 @@ \tHomepage: http://example.com \tDocumentation: https://www.example.info/gems/bestgemever/0.0.1 \tSource Code: https://example.com/user/bestgemever -\tFunding: https://example.com/has_metadata/funding \tWiki: https://example.com/user/bestgemever/wiki \tChangelog: https://example.com/user/bestgemever/CHANGELOG.md \tBug Tracker: https://example.com/user/bestgemever/issues diff --git a/bundler/spec/commands/install_spec.rb b/bundler/spec/commands/install_spec.rb index d1b8585114b3..114e03c2650d 100644 --- a/bundler/spec/commands/install_spec.rb +++ b/bundler/spec/commands/install_spec.rb @@ -141,8 +141,14 @@ end it "does not install the development dependency" do + build_repo2 do + build_gem "with_development_dependency" do |s| + s.add_development_dependency "activesupport", "= 2.3.5" + end + end + install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "with_development_dependency" G @@ -294,8 +300,11 @@ end it "finds gems in multiple sources", :bundler => "< 3" do - build_repo2 - update_repo2 + build_repo2 do + build_gem "rack", "1.2" do |s| + s.executables = "rackup" + end + end install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" diff --git a/bundler/spec/commands/licenses_spec.rb b/bundler/spec/commands/licenses_spec.rb index d4fa02d0a7e5..a20398489041 100644 --- a/bundler/spec/commands/licenses_spec.rb +++ b/bundler/spec/commands/licenses_spec.rb @@ -2,8 +2,14 @@ RSpec.describe "bundle licenses" do before :each do + build_repo2 do + build_gem "with_license" do |s| + s.license = "MIT" + end + end + install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "rails" gem "with_license" G @@ -18,7 +24,7 @@ it "performs an automatic bundle install" do gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "rails" gem "with_license" gem "foo" diff --git a/bundler/spec/commands/list_spec.rb b/bundler/spec/commands/list_spec.rb index ed3edad1637b..66930ded75a2 100644 --- a/bundler/spec/commands/list_spec.rb +++ b/bundler/spec/commands/list_spec.rb @@ -117,6 +117,10 @@ context "with paths option" do before do build_repo2 do + build_gem "rack", "1.2" do |s| + s.executables = "rackup" + end + build_gem "bar" end diff --git a/bundler/spec/commands/lock_spec.rb b/bundler/spec/commands/lock_spec.rb index c97358c62d80..cc56c3495202 100644 --- a/bundler/spec/commands/lock_spec.rb +++ b/bundler/spec/commands/lock_spec.rb @@ -15,7 +15,7 @@ def read_lockfile(file = "Gemfile.lock") gemfile <<-G source "#{file_uri_for(repo)}" gem "rails" - gem "with_license" + gem "weakling" gem "foo" G @@ -40,7 +40,7 @@ def read_lockfile(file = "Gemfile.lock") activeresource (= 2.3.2) rake (= 13.0.1) rake (13.0.1) - with_license (1.0) + weakling (0.0.3) PLATFORMS #{lockfile_platforms} @@ -48,7 +48,7 @@ def read_lockfile(file = "Gemfile.lock") DEPENDENCIES foo rails - with_license + weakling BUNDLED WITH #{Bundler::VERSION} diff --git a/bundler/spec/commands/update_spec.rb b/bundler/spec/commands/update_spec.rb index 5ab932e5d7dd..b8de6507f6e3 100644 --- a/bundler/spec/commands/update_spec.rb +++ b/bundler/spec/commands/update_spec.rb @@ -15,6 +15,10 @@ describe "with no arguments", :bundler => "< 3" do it "updates the entire bundle" do update_repo2 do + build_gem "rack", "1.2" do |s| + s.executables = "rackup" + end + build_gem "activesupport", "3.0" end @@ -38,6 +42,10 @@ describe "with --all", :bundler => "3" do it "updates the entire bundle" do update_repo2 do + build_gem "rack", "1.2" do |s| + s.executables = "rackup" + end + build_gem "activesupport", "3.0" end @@ -103,6 +111,10 @@ describe "with a top level dependency" do it "unlocks all child dependencies that are unrelated to other locked dependencies" do update_repo2 do + build_gem "rack", "1.2" do |s| + s.executables = "rackup" + end + build_gem "activesupport", "3.0" end @@ -124,7 +136,12 @@ describe "with a child dependency" do it "should update the child dependency" do - update_repo2 + update_repo2 do + build_gem "rack", "1.2" do |s| + s.executables = "rackup" + end + end + bundle "update rack" expect(the_bundle).to include_gems "rack 1.2" end @@ -217,6 +234,10 @@ gem "rack" G update_repo2 do + build_gem "rack", "1.2" do |s| + s.executables = "rackup" + end + build_gem "activesupport", "3.0" end bundle "update --group development" @@ -269,6 +290,10 @@ gem "rack" G update_repo2 do + build_gem "rack", "1.2" do |s| + s.executables = "rackup" + end + build_gem "activesupport", "3.0" end bundle "update --group development" @@ -446,6 +471,10 @@ G update_repo2 do + build_gem "rack", "1.2" do |s| + s.executables = "rackup" + end + build_gem "thin", "2.0" do |s| s.add_dependency "rack" end diff --git a/bundler/spec/install/bundler_spec.rb b/bundler/spec/install/bundler_spec.rb index e5352ab6a2f5..af1ff7225a7e 100644 --- a/bundler/spec/install/bundler_spec.rb +++ b/bundler/spec/install/bundler_spec.rb @@ -54,6 +54,12 @@ end it "works for gems with multiple versions in its dependencies" do + build_repo2 do + build_gem "multiple_versioned_deps" do |s| + s.add_dependency "weakling", ">= 0.0.1", "< 0.1" + end + end + install_gemfile <<-G source "#{file_uri_for(gem_repo2)}" @@ -93,6 +99,12 @@ it "causes a conflict if child dependencies conflict" do bundle "config set force_ruby_platform true" + update_repo2 do + build_gem "rails_pinned_to_old_activesupport" do |s| + s.add_dependency "activesupport", "= 1.2.3" + end + end + install_gemfile <<-G, :raise_on_error => false source "#{file_uri_for(gem_repo2)}" gem "activemerchant" @@ -114,6 +126,12 @@ it "causes a conflict if a child dependency conflicts with the Gemfile" do bundle "config set force_ruby_platform true" + update_repo2 do + build_gem "rails_pinned_to_old_activesupport" do |s| + s.add_dependency "activesupport", "= 1.2.3" + end + end + install_gemfile <<-G, :raise_on_error => false source "#{file_uri_for(gem_repo2)}" gem "rails_pinned_to_old_activesupport" @@ -132,6 +150,12 @@ end it "does not cause a conflict if new dependencies in the Gemfile require older dependencies than the lockfile" do + update_repo2 do + build_gem "rails_pinned_to_old_activesupport" do |s| + s.add_dependency "activesupport", "= 1.2.3" + end + end + install_gemfile <<-G source "#{file_uri_for(gem_repo2)}" gem 'rails', "2.3.2" diff --git a/bundler/spec/install/gemfile/platform_spec.rb b/bundler/spec/install/gemfile/platform_spec.rb index 41b95481cbca..a165f62bdbd9 100644 --- a/bundler/spec/install/gemfile/platform_spec.rb +++ b/bundler/spec/install/gemfile/platform_spec.rb @@ -469,13 +469,21 @@ it "still installs correctly" do simulate_platform mswin + build_repo2 do + # The rcov gem is platform mswin32, but has no arch + build_gem "rcov" do |s| + s.platform = Gem::Platform.new([nil, "mswin32", nil]) + s.write "lib/rcov.rb", "RCOV = '1.0.0'" + end + end + gemfile <<-G # Try to install gem with nil arch source "http://localgemserver.test/" gem "rcov" G - bundle :install, :artifice => "windows" + bundle :install, :artifice => "windows", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s } expect(the_bundle).to include_gems "rcov 1.0.0" end end diff --git a/bundler/spec/install/gemfile/sources_spec.rb b/bundler/spec/install/gemfile/sources_spec.rb index be41857043b4..655f91dd69d5 100644 --- a/bundler/spec/install/gemfile/sources_spec.rb +++ b/bundler/spec/install/gemfile/sources_spec.rb @@ -597,6 +597,10 @@ G build_repo2 do + build_gem "rack", "1.2" do |s| + s.executables = "rackup" + end + build_gem "bar" end diff --git a/bundler/spec/install/gems/compact_index_spec.rb b/bundler/spec/install/gems/compact_index_spec.rb index 5ef3f38fe72e..b5fca9c6adde 100644 --- a/bundler/spec/install/gems/compact_index_spec.rb +++ b/bundler/spec/install/gems/compact_index_spec.rb @@ -138,19 +138,6 @@ expect(the_bundle).to include_gems("foo 1.0") end - it "falls back when the API errors out" do - simulate_platform mswin - - gemfile <<-G - source "#{source_uri}" - gem "rcov" - G - - bundle :install, :artifice => "windows" - expect(out).to include("Fetching source index from #{source_uri}") - expect(the_bundle).to include_gems "rcov 1.0.0" - end - it "falls back when the API URL returns 403 Forbidden" do gemfile <<-G source "#{source_uri}" @@ -258,14 +245,37 @@ def require(*args) end it "does not double check for gems that are only installed locally" do - system_gems %w[rack-1.0.0 thin-1.0 net_a-1.0] + build_repo2 do + build_gem "net_a" do |s| + s.add_dependency "net_b" + s.add_dependency "net_build_extensions" + end + + build_gem "net_b" + + build_gem "net_build_extensions" do |s| + s.add_dependency "rake" + s.extensions << "Rakefile" + s.write "Rakefile", <<-RUBY + task :default do + path = File.expand_path("../lib", __FILE__) + FileUtils.mkdir_p(path) + File.open("\#{path}/net_build_extensions.rb", "w") do |f| + f.puts "NET_BUILD_EXTENSIONS = 'YES'" + end + end + RUBY + end + end + + system_gems %w[rack-1.0.0 thin-1.0 net_a-1.0], :gem_repo => gem_repo2 bundle "config set --local path.system true" ENV["BUNDLER_SPEC_ALL_REQUESTS"] = strip_whitespace(<<-EOS).strip #{source_uri}/versions #{source_uri}/info/rack EOS - install_gemfile <<-G, :artifice => "compact_index", :verbose => true + install_gemfile <<-G, :artifice => "compact_index", :verbose => true, :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s } source "#{source_uri}" gem "rack" G @@ -499,13 +509,19 @@ def require(*args) end it "does not refetch if the only unmet dependency is bundler" do + build_repo2 do + build_gem "bundler_dep" do |s| + s.add_dependency "bundler" + end + end + gemfile <<-G source "#{source_uri}" gem "bundler_dep" G - bundle :install, :artifice => "compact_index" + bundle :install, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s } expect(out).to include("Fetching gem metadata from #{source_uri}") end @@ -598,27 +614,6 @@ def require(*args) expect(the_bundle).to include_gems "rack 1.0.0" end - it "strips http basic authentication creds for modern index" do - gemfile <<-G - source "#{basic_auth_source_uri}" - gem "rack" - G - - bundle :install, :artifice => "endopint_marshal_fail_basic_authentication" - expect(out).not_to include("#{user}:#{password}") - expect(the_bundle).to include_gems "rack 1.0.0" - end - - it "strips http basic auth creds when it can't reach the server" do - gemfile <<-G - source "#{basic_auth_source_uri}" - gem "rack" - G - - bundle :install, :artifice => "endpoint_500", :raise_on_error => false - expect(out).not_to include("#{user}:#{password}") - end - it "strips http basic auth creds when warning about ambiguous sources", :bundler => "< 3" do gemfile <<-G source "#{basic_auth_source_uri}" diff --git a/bundler/spec/install/gems/dependency_api_spec.rb b/bundler/spec/install/gems/dependency_api_spec.rb index e92669e97c53..5e0be8999530 100644 --- a/bundler/spec/install/gems/dependency_api_spec.rb +++ b/bundler/spec/install/gems/dependency_api_spec.rb @@ -121,12 +121,20 @@ it "falls back when the API errors out" do simulate_platform mswin + build_repo2 do + # The rcov gem is platform mswin32, but has no arch + build_gem "rcov" do |s| + s.platform = Gem::Platform.new([nil, "mswin32", nil]) + s.write "lib/rcov.rb", "RCOV = '1.0.0'" + end + end + gemfile <<-G source "#{source_uri}" gem "rcov" G - bundle :install, :artifice => "windows" + bundle :install, :artifice => "windows", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s } expect(out).to include("Fetching source index from #{source_uri}") expect(the_bundle).to include_gems "rcov 1.0.0" end @@ -473,13 +481,19 @@ def require(*args) end it "does not refetch if the only unmet dependency is bundler" do + build_repo2 do + build_gem "bundler_dep" do |s| + s.add_dependency "bundler" + end + end + gemfile <<-G source "#{source_uri}" gem "bundler_dep" G - bundle :install, :artifice => "endpoint" + bundle :install, :artifice => "endpoint", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s } expect(out).to include("Fetching gem metadata from #{source_uri}") end @@ -578,7 +592,7 @@ def require(*args) gem "rack" G - bundle :install, :artifice => "endopint_marshal_fail_basic_authentication" + bundle :install, :artifice => "endpoint_marshal_fail_basic_authentication" expect(out).not_to include("#{user}:#{password}") expect(the_bundle).to include_gems "rack 1.0.0" end diff --git a/bundler/spec/install/gems/flex_spec.rb b/bundler/spec/install/gems/flex_spec.rb index 858c40c07c76..7ab0ded26df7 100644 --- a/bundler/spec/install/gems/flex_spec.rb +++ b/bundler/spec/install/gems/flex_spec.rb @@ -166,8 +166,7 @@ expect(the_bundle).to include_gems "rack_middleware 1.0", "rack 0.9.1" - build_repo2 - update_repo2 do + build_repo2 do build_gem "rack-obama", "2.0" do |s| s.add_dependency "rack", "=1.2" end diff --git a/bundler/spec/install/gems/fund_spec.rb b/bundler/spec/install/gems/fund_spec.rb index 57e7c3aed393..f521b0296f31 100644 --- a/bundler/spec/install/gems/fund_spec.rb +++ b/bundler/spec/install/gems/fund_spec.rb @@ -2,11 +2,38 @@ RSpec.describe "bundle install" do context "with gem sources" do + before do + build_repo2 do + build_gem "has_funding_and_other_metadata" do |s| + s.metadata = { + "bug_tracker_uri" => "https://example.com/user/bestgemever/issues", + "changelog_uri" => "https://example.com/user/bestgemever/CHANGELOG.md", + "documentation_uri" => "https://www.example.info/gems/bestgemever/0.0.1", + "homepage_uri" => "https://bestgemever.example.io", + "mailing_list_uri" => "https://groups.example.com/bestgemever", + "funding_uri" => "https://example.com/has_funding_and_other_metadata/funding", + "source_code_uri" => "https://example.com/user/bestgemever", + "wiki_uri" => "https://example.com/user/bestgemever/wiki", + } + end + + build_gem "has_funding", "1.2.3" do |s| + s.metadata = { + "funding_uri" => "https://example.com/has_funding/funding", + } + end + + build_gem "gem_with_dependent_funding", "1.0" do |s| + s.add_dependency "has_funding" + end + end + end + context "when gems include a fund URI" do it "displays the plural fund message after installing" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" - gem 'has_metadata' + source "#{file_uri_for(gem_repo2)}" + gem 'has_funding_and_other_metadata' gem 'has_funding' gem 'rack-obama' G @@ -16,7 +43,7 @@ it "displays the singular fund message after installing" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem 'has_funding' gem 'rack-obama' G @@ -28,7 +55,7 @@ context "when gems do not include fund messages" do it "does not display any fund messages" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "activesupport" G @@ -39,7 +66,7 @@ context "when a dependency includes a fund message" do it "does not display the fund message" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem 'gem_with_dependent_funding' G diff --git a/bundler/spec/install/gems/resolving_spec.rb b/bundler/spec/install/gems/resolving_spec.rb index f621b0136672..307376f11918 100644 --- a/bundler/spec/install/gems/resolving_spec.rb +++ b/bundler/spec/install/gems/resolving_spec.rb @@ -1,9 +1,46 @@ # frozen_string_literal: true RSpec.describe "bundle install with install-time dependencies" do + before do + build_repo2 do + # Test complicated gem dependencies for install + build_gem "net_a" do |s| + s.add_dependency "net_b" + s.add_dependency "net_build_extensions" + end + + build_gem "net_b" + + build_gem "net_build_extensions" do |s| + s.add_dependency "rake" + s.extensions << "Rakefile" + s.write "Rakefile", <<-RUBY + task :default do + path = File.expand_path("../lib", __FILE__) + FileUtils.mkdir_p(path) + File.open("\#{path}/net_build_extensions.rb", "w") do |f| + f.puts "NET_BUILD_EXTENSIONS = 'YES'" + end + end + RUBY + end + + build_gem "net_c" do |s| + s.add_dependency "net_a" + s.add_dependency "net_d" + end + + build_gem "net_d" + + build_gem "net_e" do |s| + s.add_dependency "net_d" + end + end + end + it "installs gems with implicit rake dependencies" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "with_implicit_rake_dep" gem "another_implicit_rake_dep" gem "rake" @@ -43,7 +80,7 @@ describe "with crazy rubygem plugin stuff" do it "installs plugins" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "net_b" G @@ -52,7 +89,7 @@ it "installs plugins depended on by other plugins" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "net_a" G @@ -61,7 +98,7 @@ it "installs multiple levels of dependencies" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "net_c" gem "net_e" G @@ -72,7 +109,7 @@ context "with ENV['BUNDLER_DEBUG_RESOLVER'] set" do it "produces debug output" do gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "net_c" gem "net_e" G @@ -86,7 +123,7 @@ context "with ENV['DEBUG_RESOLVER'] set" do it "produces debug output" do gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "net_c" gem "net_e" G @@ -100,7 +137,7 @@ context "with ENV['DEBUG_RESOLVER_TREE'] set" do it "produces debug output" do gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "net_c" gem "net_e" G @@ -126,6 +163,10 @@ it "installs the older version" do build_repo2 do + build_gem "rack", "1.2" do |s| + s.executables = "rackup" + end + build_gem "rack", "9001.0.0" do |s| s.required_ruby_version = "> 9000" end diff --git a/bundler/spec/install/prereleases_spec.rb b/bundler/spec/install/prereleases_spec.rb index fb01220ed7a5..c3f968ad70be 100644 --- a/bundler/spec/install/prereleases_spec.rb +++ b/bundler/spec/install/prereleases_spec.rb @@ -1,10 +1,19 @@ # frozen_string_literal: true RSpec.describe "bundle install" do + before do + build_repo2 do + build_gem "not_released", "1.0.pre" + + build_gem "has_prerelease", "1.0" + build_gem "has_prerelease", "1.1.pre" + end + end + describe "when prerelease gems are available" do it "finds prereleases" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "not_released" G expect(the_bundle).to include_gems "not_released 1.0.pre" @@ -12,7 +21,7 @@ it "uses regular releases if available" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "has_prerelease" G expect(the_bundle).to include_gems "has_prerelease 1.0" @@ -20,7 +29,7 @@ it "uses prereleases if requested" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "has_prerelease", "1.1.pre" G expect(the_bundle).to include_gems "has_prerelease 1.1.pre" diff --git a/bundler/spec/lock/lockfile_spec.rb b/bundler/spec/lock/lockfile_spec.rb index d26dc789cc72..98272811f871 100644 --- a/bundler/spec/lock/lockfile_spec.rb +++ b/bundler/spec/lock/lockfile_spec.rb @@ -3,16 +3,28 @@ RSpec.describe "the lockfile format" do include Bundler::GemHelpers + before do + build_repo2 do + # Capistrano did this (at least until version 2.5.10) + # RubyGems 2.2 doesn't allow the specifying of a dependency twice + # See https://github.com/rubygems/rubygems/commit/03dbac93a3396a80db258d9bc63500333c25bd2f + build_gem "double_deps", "1.0", :skip_validation => true do |s| + s.add_dependency "net-ssh", ">= 1.0.0" + s.add_dependency "net-ssh" + end + end + end + it "generates a simple lockfile for a single source, gem" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "rack" G lockfile_should_be <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (1.0.0) @@ -37,7 +49,7 @@ specs: GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (1.0.0) @@ -53,14 +65,14 @@ L install_gemfile <<-G, :env => { "BUNDLER_VERSION" => Bundler::VERSION } - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "rack" G lockfile_should_be <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (1.0.0) @@ -80,7 +92,7 @@ lockfile <<-L GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (1.0.0) @@ -95,14 +107,14 @@ L install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "rack" G lockfile_should_be <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (1.0.0) @@ -120,7 +132,7 @@ it "updates the lockfile's bundler version if not present" do lockfile <<-L GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (1.0.0) @@ -132,14 +144,14 @@ L install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "rack", "> 0" G lockfile_should_be <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (1.0.0) @@ -160,7 +172,7 @@ lockfile <<-L GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (1.0.0) @@ -175,7 +187,7 @@ L install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "rack" G @@ -189,7 +201,7 @@ lockfile_should_be <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (1.0.0) @@ -212,7 +224,7 @@ lockfile <<-L GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (1.0.0) @@ -227,7 +239,7 @@ L install_gemfile <<-G, :env => { "BUNDLER_VERSION" => Bundler::VERSION } - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" gem "rack" G @@ -239,7 +251,7 @@ lockfile_should_be <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (1.0.0) @@ -256,14 +268,14 @@ it "generates a simple lockfile for a single source, gem with dependencies" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" gem "rack-obama" G lockfile_should_be <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (1.0.0) rack-obama (1.0) @@ -282,14 +294,14 @@ it "generates a simple lockfile for a single source, gem with a version requirement" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" gem "rack-obama", ">= 1.0" G lockfile_should_be <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (1.0.0) rack-obama (1.0) @@ -380,13 +392,13 @@ it "generates lockfiles with multiple requirements" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" gem "net-sftp" G lockfile_should_be <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: net-sftp (1.1.1) net-ssh (>= 1.0.0, < 1.99.0) @@ -465,7 +477,7 @@ build_lib "omg", :path => lib_path("omg") gemfile <<-G - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" platforms :#{not_local_tag} do gem "omg", :path => "#{lib_path("omg")}" @@ -481,7 +493,7 @@ specs: GEM - remote: #{file_uri_for(gem_repo1)}// + remote: #{file_uri_for(gem_repo2)}// specs: rack (1.0.0) @@ -653,7 +665,7 @@ bar = build_git "bar" install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" gem "rack" gem "foo", :path => "#{lib_path("foo-1.0")}" @@ -673,7 +685,7 @@ foo (1.0) GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (1.0.0) @@ -692,7 +704,7 @@ it "lists gems alphabetically" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" gem "thin" gem "actionpack" @@ -701,7 +713,7 @@ lockfile_should_be <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: actionpack (2.3.2) activesupport (= 2.3.2) @@ -727,14 +739,14 @@ it "orders dependencies' dependencies in alphabetical order" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" gem "rails" G lockfile_should_be <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: actionmailer (2.3.2) activesupport (= 2.3.2) @@ -766,13 +778,13 @@ it "orders dependencies by version" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" gem 'double_deps' G lockfile_should_be <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: double_deps (1.0) net-ssh @@ -792,14 +804,14 @@ it "does not add the :require option to the lockfile" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" gem "rack-obama", ">= 1.0", :require => "rack/obama" G lockfile_should_be <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (1.0.0) rack-obama (1.0) @@ -818,14 +830,14 @@ it "does not add the :group option to the lockfile" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" gem "rack-obama", ">= 1.0", :group => :test G lockfile_should_be <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (1.0.0) rack-obama (1.0) @@ -959,7 +971,7 @@ it "keeps existing platforms in the lockfile", :bundler => "< 3" do lockfile <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (1.0.0) @@ -974,14 +986,14 @@ G install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" gem "rack" G lockfile_should_be <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (1.0.0) @@ -1000,7 +1012,7 @@ it "keeps existing platforms in the lockfile", :bundler => "3" do lockfile <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (1.0.0) @@ -1015,14 +1027,14 @@ G install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" gem "rack" G lockfile_should_be <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (1.0.0) @@ -1105,19 +1117,19 @@ it "does not add duplicate gems" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" gem "rack" G install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" gem "rack" gem "activesupport" G lockfile_should_be <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: activesupport (2.3.5) rack (1.0.0) @@ -1136,14 +1148,14 @@ it "does not add duplicate dependencies" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" gem "rack" gem "rack" G lockfile_should_be <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (1.0.0) @@ -1160,14 +1172,14 @@ it "does not add duplicate dependencies with versions" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" gem "rack", "1.0" gem "rack", "1.0" G lockfile_should_be <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (1.0.0) @@ -1184,14 +1196,14 @@ it "does not add duplicate dependencies in different groups" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" gem "rack", "1.0", :group => :one gem "rack", "1.0", :group => :two G lockfile_should_be <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (1.0.0) @@ -1208,7 +1220,7 @@ it "raises if two different versions are used" do install_gemfile <<-G, :raise_on_error => false - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" gem "rack", "1.0" gem "rack", "1.1" G @@ -1219,7 +1231,7 @@ it "raises if two different sources are used" do install_gemfile <<-G, :raise_on_error => false - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" gem "rack" gem "rack", :git => "git://hubz.com" G @@ -1230,13 +1242,13 @@ it "works correctly with multiple version dependencies" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" gem "rack", "> 0.9", "< 1.0" G lockfile_should_be <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (0.9.1) @@ -1253,14 +1265,14 @@ it "captures the Ruby version in the lockfile" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" ruby '#{RUBY_VERSION}' gem "rack", "> 0.9", "< 1.0" G lockfile_should_be <<-G GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack (0.9.1) @@ -1289,7 +1301,7 @@ revision = revision_for(lib_path("omg")) gemfile <<-G - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" gem "omg", :git => "#{lib_path("omg")}", :branch => 'master' G @@ -1314,7 +1326,7 @@ omg (1.0) GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: PLATFORMS @@ -1341,7 +1353,7 @@ omg (1.0) GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: PLATFORMS @@ -1358,7 +1370,7 @@ it "raises a helpful error message when the lockfile is missing deps" do lockfile <<-L GEM - remote: #{file_uri_for(gem_repo1)}/ + remote: #{file_uri_for(gem_repo2)}/ specs: rack_middleware (1.0) @@ -1370,7 +1382,7 @@ L install_gemfile <<-G, :raise_on_error => false - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "rack_middleware" G @@ -1400,7 +1412,11 @@ def set_lockfile_mtime_to_known_value context "during updates" do it "preserves Gemfile.lock \\n line endings" do - update_repo2 + update_repo2 do + build_gem "rack", "1.2" do |s| + s.executables = "rackup" + end + end expect { bundle "update", :all => true }.to change { File.mtime(bundled_app_lock) } expect(File.read(bundled_app_lock)).not_to match("\r\n") @@ -1410,7 +1426,12 @@ def set_lockfile_mtime_to_known_value it "preserves Gemfile.lock \\n\\r line endings" do skip "needs to be adapted" if Gem.win_platform? - update_repo2 + update_repo2 do + build_gem "rack", "1.2" do |s| + s.executables = "rackup" + end + end + win_lock = File.read(bundled_app_lock).gsub(/\n/, "\r\n") File.open(bundled_app_lock, "wb") {|f| f.puts(win_lock) } set_lockfile_mtime_to_known_value @@ -1449,7 +1470,7 @@ def set_lockfile_mtime_to_known_value it "refuses to install if Gemfile.lock contains conflict markers" do lockfile <<-L GEM - remote: #{file_uri_for(gem_repo1)}// + remote: #{file_uri_for(gem_repo2)}// specs: <<<<<<< rack (1.0.0) @@ -1468,7 +1489,7 @@ def set_lockfile_mtime_to_known_value L install_gemfile <<-G, :raise_on_error => false - source "#{file_uri_for(gem_repo1)}/" + source "#{file_uri_for(gem_repo2)}/" gem "rack" G diff --git a/bundler/spec/other/platform_spec.rb b/bundler/spec/other/platform_spec.rb index a8fd4d51fbab..eb3539b412a9 100644 --- a/bundler/spec/other/platform_spec.rb +++ b/bundler/spec/other/platform_spec.rb @@ -496,6 +496,10 @@ def should_be_patchlevel_fixnum #{ruby_version_correct} G update_repo2 do + build_gem "rack", "1.2" do |s| + s.executables = "rackup" + end + build_gem "activesupport", "3.0" end @@ -512,6 +516,10 @@ def should_be_patchlevel_fixnum #{ruby_version_correct_engineless} G update_repo2 do + build_gem "rack", "1.2" do |s| + s.executables = "rackup" + end + build_gem "activesupport", "3.0" end diff --git a/bundler/spec/support/artifice/endopint_marshal_fail_basic_authentication.rb b/bundler/spec/support/artifice/endpoint_marshal_fail_basic_authentication.rb similarity index 100% rename from bundler/spec/support/artifice/endopint_marshal_fail_basic_authentication.rb rename to bundler/spec/support/artifice/endpoint_marshal_fail_basic_authentication.rb diff --git a/bundler/spec/support/builders.rb b/bundler/spec/support/builders.rb index a1770759a9df..dca784f1b091 100644 --- a/bundler/spec/support/builders.rb +++ b/bundler/spec/support/builders.rb @@ -76,14 +76,6 @@ def build_repo1 s.add_dependency "activesupport", ">= 2.0.0" end - build_gem "rails_pinned_to_old_activesupport" do |s| - s.add_dependency "activesupport", "= 1.2.3" - end - - build_gem "missing_dep" do |s| - s.add_dependency "not_here" - end - build_gem "rspec", "1.2.7", :no_default => true do |s| s.write "lib/spec.rb", "SPEC = '1.2.7'" end @@ -158,23 +150,6 @@ def build_repo1 build_gem "duradura", "7.0" - build_gem "multiple_versioned_deps" do |s| - s.add_dependency "weakling", ">= 0.0.1", "< 0.1" - end - - build_gem "not_released", "1.0.pre" - - build_gem "has_prerelease", "1.0" - build_gem "has_prerelease", "1.1.pre" - - build_gem "with_development_dependency" do |s| - s.add_development_dependency "activesupport", "= 2.3.5" - end - - build_gem "with_license" do |s| - s.license = "MIT" - end - build_gem "with_implicit_rake_dep" do |s| s.extensions << "Rakefile" s.write "Rakefile", <<-RUBY @@ -215,10 +190,6 @@ def build_repo1 s.write "lib/rubygems_plugin.rb", "require 'bundler/omg' ; puts 'FAIL'" end - build_gem "bundler_dep" do |s| - s.add_dependency "bundler" - end - # The yard gem iterates over Gem.source_index looking for plugins build_gem "yard" do |s| s.write "lib/yard.rb", <<-Y @@ -228,115 +199,12 @@ def build_repo1 Y end - # The rcov gem is platform mswin32, but has no arch - build_gem "rcov" do |s| - s.platform = Gem::Platform.new([nil, "mswin32", nil]) - s.write "lib/rcov.rb", "RCOV = '1.0.0'" - end - build_gem "net-ssh" build_gem "net-sftp", "1.1.1" do |s| s.add_dependency "net-ssh", ">= 1.0.0", "< 1.99.0" end - # Test complicated gem dependencies for install - build_gem "net_a" do |s| - s.add_dependency "net_b" - s.add_dependency "net_build_extensions" - end - - build_gem "net_b" - - build_gem "net_build_extensions" do |s| - s.add_dependency "rake" - s.extensions << "Rakefile" - s.write "Rakefile", <<-RUBY - task :default do - path = File.expand_path("../lib", __FILE__) - FileUtils.mkdir_p(path) - File.open("\#{path}/net_build_extensions.rb", "w") do |f| - f.puts "NET_BUILD_EXTENSIONS = 'YES'" - end - end - RUBY - end - - build_gem "net_c" do |s| - s.add_dependency "net_a" - s.add_dependency "net_d" - end - - build_gem "net_d" - - build_gem "net_e" do |s| - s.add_dependency "net_d" - end - - # Capistrano did this (at least until version 2.5.10) - # RubyGems 2.2 doesn't allow the specifying of a dependency twice - # See https://github.com/rubygems/rubygems/commit/03dbac93a3396a80db258d9bc63500333c25bd2f - build_gem "double_deps", "1.0", :skip_validation => true do |s| - s.add_dependency "net-ssh", ">= 1.0.0" - s.add_dependency "net-ssh" - end - build_gem "foo" - - # A minimal fake pry console - build_gem "pry" do |s| - s.write "lib/pry.rb", <<-RUBY - class Pry - class << self - def toplevel_binding - unless defined?(@toplevel_binding) && @toplevel_binding - TOPLEVEL_BINDING.eval %{ - def self.__pry__; binding; end - Pry.instance_variable_set(:@toplevel_binding, __pry__) - class << self; undef __pry__; end - } - end - @toplevel_binding.eval('private') - @toplevel_binding - end - - def __pry__ - while line = gets - begin - puts eval(line, toplevel_binding).inspect.sub(/^"(.*)"$/, '=> \\1') - rescue Exception => e - puts "\#{e.class}: \#{e.message}" - puts e.backtrace.first - end - end - end - alias start __pry__ - end - end - RUBY - end - - build_gem "has_metadata" do |s| - s.metadata = { - "bug_tracker_uri" => "https://example.com/user/bestgemever/issues", - "changelog_uri" => "https://example.com/user/bestgemever/CHANGELOG.md", - "documentation_uri" => "https://www.example.info/gems/bestgemever/0.0.1", - "homepage_uri" => "https://bestgemever.example.io", - "mailing_list_uri" => "https://groups.example.com/bestgemever", - "funding_uri" => "https://example.com/has_metadata/funding", - "source_code_uri" => "https://example.com/user/bestgemever", - "wiki_uri" => "https://example.com/user/bestgemever/wiki", - } - end - - build_gem "has_funding", "1.2.3" do |s| - s.metadata = { - "funding_uri" => "https://example.com/has_funding/funding", - } - end - - build_gem "gem_with_dependent_funding", "1.0" do |s| - s.add_dependency "has_funding" - end end end @@ -366,9 +234,6 @@ def update_repo4(&blk) def update_repo2 update_repo gem_repo2 do - build_gem "rack", "1.2" do |s| - s.executables = "rackup" - end yield if block_given? end end diff --git a/bundler/spec/update/gems/fund_spec.rb b/bundler/spec/update/gems/fund_spec.rb index 6d7075b42412..0dfe63d36d8b 100644 --- a/bundler/spec/update/gems/fund_spec.rb +++ b/bundler/spec/update/gems/fund_spec.rb @@ -2,9 +2,30 @@ RSpec.describe "bundle update" do before do + build_repo2 do + build_gem "has_funding_and_other_metadata" do |s| + s.metadata = { + "bug_tracker_uri" => "https://example.com/user/bestgemever/issues", + "changelog_uri" => "https://example.com/user/bestgemever/CHANGELOG.md", + "documentation_uri" => "https://www.example.info/gems/bestgemever/0.0.1", + "homepage_uri" => "https://bestgemever.example.io", + "mailing_list_uri" => "https://groups.example.com/bestgemever", + "funding_uri" => "https://example.com/has_funding_and_other_metadata/funding", + "source_code_uri" => "https://example.com/user/bestgemever", + "wiki_uri" => "https://example.com/user/bestgemever/wiki", + } + end + + build_gem "has_funding", "1.2.3" do |s| + s.metadata = { + "funding_uri" => "https://example.com/has_funding/funding", + } + end + end + gemfile <<-G - source "#{file_uri_for(gem_repo1)}" - gem 'has_metadata' + source "#{file_uri_for(gem_repo2)}" + gem 'has_funding_and_other_metadata' gem 'has_funding', '< 2.0' G @@ -14,8 +35,8 @@ context "when listed gems are updated" do before do gemfile <<-G - source "#{file_uri_for(gem_repo1)}" - gem 'has_metadata' + source "#{file_uri_for(gem_repo2)}" + gem 'has_funding_and_other_metadata' gem 'has_funding' G