summaryrefslogtreecommitdiff
path: root/spec/bundler/commands
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2020-10-15 13:20:25 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-10-15 17:19:02 +0900
commitd386a58f6f1865aaa35eda5af55cff3ff3cca4ca (patch)
tree0665fe806540deae7f8e52095af6dba70f940aa3 /spec/bundler/commands
parent7ffd14a18c341565afaf80d259f9fe5df8a13d29 (diff)
Merge bundler-2.2.0.rc.2
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3659
Diffstat (limited to 'spec/bundler/commands')
-rw-r--r--spec/bundler/commands/clean_spec.rb26
-rw-r--r--spec/bundler/commands/fund_spec.rb55
-rw-r--r--spec/bundler/commands/help_spec.rb8
-rw-r--r--spec/bundler/commands/info_spec.rb1
-rw-r--r--spec/bundler/commands/install_spec.rb28
-rw-r--r--spec/bundler/commands/newgem_spec.rb5
-rw-r--r--spec/bundler/commands/outdated_spec.rb4
7 files changed, 118 insertions, 9 deletions
diff --git a/spec/bundler/commands/clean_spec.rb b/spec/bundler/commands/clean_spec.rb
index 0ecdf230f9..bd8e7f16c7 100644
--- a/spec/bundler/commands/clean_spec.rb
+++ b/spec/bundler/commands/clean_spec.rb
@@ -625,6 +625,32 @@ RSpec.describe "bundle clean" do
expect(out).to eq("1.0")
end
+ it "when using --force, it doesn't remove default gem binaries" do
+ skip "does not work on ruby 3.0 because it changes the path to look for default gems, tsort is a default gem there, and we can't install it either like we do with fiddle because it doesn't yet exist" unless RUBY_VERSION < "3.0.0"
+
+ skip "does not work on rubygems versions where `--install_dir` doesn't respect --default" unless Gem::Installer.for_spec(loaded_gemspec, :install_dir => "/foo").default_spec_file == "/foo/specifications/default/bundler-#{Bundler::VERSION}.gemspec" # Since rubygems 3.2.0.rc.2
+
+ default_irb_version = ruby "gem 'irb', '< 999999'; require 'irb'; puts IRB::VERSION", :raise_on_error => false
+ skip "irb isn't a default gem" if default_irb_version.empty?
+
+ build_repo2 do
+ # simulate executable for default gem
+ build_gem "irb", default_irb_version, :to_system => true, :default => true do |s|
+ s.executables = "irb"
+ end
+ end
+
+ realworld_system_gems "fiddle"
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo2)}"
+ G
+
+ bundle "clean --force", :env => { "BUNDLER_GEM_DEFAULT_DIR" => system_gem_path.to_s }
+
+ expect(out).not_to include("Removing irb")
+ end
+
it "doesn't blow up on path gems without a .gemspec" do
relative_path = "vendor/private_gems/bar-1.0"
absolute_path = bundled_app(relative_path)
diff --git a/spec/bundler/commands/fund_spec.rb b/spec/bundler/commands/fund_spec.rb
new file mode 100644
index 0000000000..ee3aff3a29
--- /dev/null
+++ b/spec/bundler/commands/fund_spec.rb
@@ -0,0 +1,55 @@
+# frozen_string_literal: true
+
+RSpec.describe "bundle fund" do
+ it "prints fund information for all gems in the bundle" do
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo1)}"
+ gem 'has_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 (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)}"
+ gem 'gem_with_dependent_funding'
+ G
+
+ bundle "fund"
+
+ expect(out).to_not include("* has_funding (1.2.3)\n Funding: https://example.com/has_funding/funding")
+ expect(out).to_not include("gem_with_dependent_funding")
+ end
+
+ it "prints message if none of the gems have fund information" do
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo1)}"
+ gem 'rack-obama'
+ G
+
+ bundle "fund"
+
+ expect(out).to include("None of the installed gems you directly depend on are looking for funding.")
+ end
+
+ 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
+ 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_not include("* has_funding (1.2.3)\n Funding: https://example.com/has_funding/funding")
+ end
+ end
+end
diff --git a/spec/bundler/commands/help_spec.rb b/spec/bundler/commands/help_spec.rb
index 788c1b8d29..03d34ef692 100644
--- a/spec/bundler/commands/help_spec.rb
+++ b/spec/bundler/commands/help_spec.rb
@@ -1,25 +1,25 @@
# frozen_string_literal: true
RSpec.describe "bundle help" do
- it "uses mann when available" do
+ it "uses man when available" do
with_fake_man do
bundle "help gemfile"
end
expect(out).to eq(%(["#{root}/man/gemfile.5"]))
end
- it "prefixes bundle commands with bundle- when finding the groff files" do
+ it "prefixes bundle commands with bundle- when finding the man files" do
with_fake_man do
bundle "help install"
end
expect(out).to eq(%(["#{root}/man/bundle-install.1"]))
end
- it "simply outputs the txt file when there is no man on the path" do
+ it "simply outputs the human readable file when there is no man on the path" do
with_path_as("") do
bundle "help install"
end
- expect(out).to match(/BUNDLE-INSTALL/)
+ expect(out).to match(/bundle-install/)
end
it "still outputs the old help for commands that do not have man pages yet" do
diff --git a/spec/bundler/commands/info_spec.rb b/spec/bundler/commands/info_spec.rb
index 9286e6824a..eec9c773bc 100644
--- a/spec/bundler/commands/info_spec.rb
+++ b/spec/bundler/commands/info_spec.rb
@@ -66,6 +66,7 @@ RSpec.describe "bundle info" do
\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/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb
index 98290bbc9e..d1b8585114 100644
--- a/spec/bundler/commands/install_spec.rb
+++ b/spec/bundler/commands/install_spec.rb
@@ -497,11 +497,21 @@ RSpec.describe "bundle install with gem sources" do
#{Bundler::VERSION}
L
end
+
+ it "does not crash when unlocking" do
+ gemfile <<-G
+ ruby '>= 2.1.0'
+ G
+
+ bundle "update"
+
+ expect(err).not_to include("Could not find gem 'Ruby")
+ end
end
end
describe "when Bundler root contains regex chars" do
- it "doesn't blow up" do
+ it "doesn't blow up when using the `gem` DSL" do
root_dir = tmp("foo[]bar")
FileUtils.mkdir_p(root_dir)
@@ -516,6 +526,22 @@ RSpec.describe "bundle install with gem sources" do
bundle :install, :dir => root_dir
end
+
+ it "doesn't blow up when using the `gemspec` DSL" do
+ root_dir = tmp("foo[]bar")
+
+ FileUtils.mkdir_p(root_dir)
+
+ build_lib "foo", :path => root_dir
+ gemfile = <<-G
+ gemspec
+ G
+ File.open("#{root_dir}/Gemfile", "w") do |file|
+ file.puts gemfile
+ end
+
+ bundle :install, :dir => root_dir
+ end
end
describe "when requesting a quiet install via --quiet" do
diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb
index 70419f612d..beee2b0fdc 100644
--- a/spec/bundler/commands/newgem_spec.rb
+++ b/spec/bundler/commands/newgem_spec.rb
@@ -12,11 +12,12 @@ RSpec.describe "bundle gem" do
def bundle_exec_rubocop
prepare_gemspec(bundled_app(gem_name, "#{gem_name}.gemspec"))
- rubocop_version = RUBY_VERSION > "2.4" ? "0.85.1" : "0.80.1"
+ rubocop_version = RUBY_VERSION > "2.4" ? "0.90.0" : "0.80.1"
gems = ["minitest", "rake", "rake-compiler", "rspec", "rubocop -v #{rubocop_version}", "test-unit"]
+ gems += ["rubocop-ast -v 0.4.0"] if rubocop_version == "0.90.0"
path = Bundler.feature_flag.default_install_uses_path? ? local_gem_path(:base => bundled_app(gem_name)) : system_gem_path
realworld_system_gems gems, :path => path
- bundle "exec rubocop --config .rubocop.yml", :dir => bundled_app(gem_name)
+ bundle "exec rubocop --debug --config .rubocop.yml", :dir => bundled_app(gem_name)
end
let(:generated_gemspec) { Bundler.load_gemspec_uncached(bundled_app(gem_name).join("#{gem_name}.gemspec")) }
diff --git a/spec/bundler/commands/outdated_spec.rb b/spec/bundler/commands/outdated_spec.rb
index 2a07f1c784..1faee23f26 100644
--- a/spec/bundler/commands/outdated_spec.rb
+++ b/spec/bundler/commands/outdated_spec.rb
@@ -555,7 +555,7 @@ RSpec.describe "bundle outdated" do
end
end
- context "after bundle config set deployment true" do
+ context "after bundle config set --local deployment true" do
before do
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
@@ -563,7 +563,7 @@ RSpec.describe "bundle outdated" do
gem "rack"
gem "foo"
G
- bundle "config set deployment true"
+ bundle "config set --local deployment true"
end
it "outputs a helpful message about being in deployment mode" do