mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
5a384e2c08
* These seem to consistenly pass already * Show actual command when running `make test-bundler` Current the setup command that installs the necessary gems for testing bundler was printed, but not the actual command that runs the tests. That was a bit confusing. * Borrow trick from setproctitle specs * A title that long doesn't get set sometimes No idea why, but the test doesn't need that the title is that long. * Fix most gem helper spec ruby-core failures * Fix the rest of the gem helper failures * Fix version spec by improving the assertion * Remove unnecessary `BUNDLE_RUBY` environment var We can use `RUBY` when necessary, and `BUNDLE_RUBY` is not a good name because bundler considers `BUNDLE_*` variables as settings. * Rename `BUNDLE_GEM` to `GEM_COMMAND` This is more descriptive I think, and also friendlier for bundler because `BUNDLE_` env variables are interpreted by bundler as settings, and this is not a bundler setting. This fixes one bundler spec failure in config specs against ruby-core. * Fix quality spec when run in core Use the proper path helper. * Fix dummy lib builder to never load default gems If a dummy library is named as a default gem, when requiring the library from its executable, the default gem would be loaded when running from core, because in core all default gems share path with bundler, and thus they are always in the $LOAD_PATH. We fix the issue by loading lib relatively inside dummy lib executables. * More exact assertions Sometimes I have the problem that I do some "print debugging" inside specs, and suddently the spec passes. This happens when the assertion is too relaxed, and the things I print make it match, specially when they are simple strings like "1.0" than can be easily be part of gem paths that I print for debugging. I fix this by making a more exact assertion. * Detect the correct shebang when ENV["RUBY"] is set * Relax assertion So that the spec passes even if another paths containing "ext" are in the load path. This works to fix a ruby-core issue, but it's a better assertion in general. We just want to know that the extension path was added. * Use folder structure independent path helper It should fix this spec for ruby-core. * Fix the last failing spec on ruby-core * Skip `bundle open <default_gem>` spec when no default gems
225 lines
5.9 KiB
Ruby
225 lines
5.9 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe "bundle show", :bundler => "< 3" do
|
|
context "with a standard Gemfile" do
|
|
before :each do
|
|
install_gemfile <<-G
|
|
source "#{file_uri_for(gem_repo1)}"
|
|
gem "rails"
|
|
G
|
|
end
|
|
|
|
it "creates a Gemfile.lock if one did not exist" do
|
|
FileUtils.rm("Gemfile.lock")
|
|
|
|
bundle "show"
|
|
|
|
expect(bundled_app("Gemfile.lock")).to exist
|
|
end
|
|
|
|
it "creates a Gemfile.lock when invoked with a gem name" do
|
|
FileUtils.rm("Gemfile.lock")
|
|
|
|
bundle "show rails"
|
|
|
|
expect(bundled_app("Gemfile.lock")).to exist
|
|
end
|
|
|
|
it "prints path if gem exists in bundle" do
|
|
bundle "show rails"
|
|
expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s)
|
|
end
|
|
|
|
it "prints path if gem exists in bundle (with --paths option)" do
|
|
bundle "show rails --paths"
|
|
expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s)
|
|
end
|
|
|
|
it "warns if path no longer exists on disk" do
|
|
FileUtils.rm_rf(default_bundle_path("gems", "rails-2.3.2"))
|
|
|
|
bundle "show rails"
|
|
|
|
expect(err).to match(/has been deleted/i)
|
|
expect(err).to match(default_bundle_path("gems", "rails-2.3.2").to_s)
|
|
end
|
|
|
|
it "prints the path to the running bundler" do
|
|
bundle "show bundler"
|
|
expect(out).to eq(root.to_s)
|
|
end
|
|
|
|
it "complains if gem not in bundle" do
|
|
bundle "show missing"
|
|
expect(err).to match(/could not find gem 'missing'/i)
|
|
end
|
|
|
|
it "prints path of all gems in bundle sorted by name" do
|
|
bundle "show --paths"
|
|
|
|
expect(out).to include(default_bundle_path("gems", "rake-12.3.2").to_s)
|
|
expect(out).to include(default_bundle_path("gems", "rails-2.3.2").to_s)
|
|
|
|
# Gem names are the last component of their path.
|
|
gem_list = out.split.map {|p| p.split("/").last }
|
|
expect(gem_list).to eq(gem_list.sort)
|
|
end
|
|
|
|
it "prints summary of gems" do
|
|
bundle "show --verbose"
|
|
|
|
expect(out).to include <<~MSG
|
|
* actionmailer (2.3.2)
|
|
\tSummary: This is just a fake gem for testing
|
|
\tHomepage: http://example.com
|
|
\tStatus: Up to date
|
|
MSG
|
|
end
|
|
|
|
it "includes bundler in the summary of gems" do
|
|
bundle "show --verbose"
|
|
|
|
expect(out).to include <<~MSG
|
|
* bundler (#{Bundler::VERSION})
|
|
\tSummary: The best way to manage your application's dependencies
|
|
\tHomepage: https://bundler.io
|
|
\tStatus: Up to date
|
|
MSG
|
|
end
|
|
end
|
|
|
|
context "with a git repo in the Gemfile" do
|
|
before :each do
|
|
@git = build_git "foo", "1.0"
|
|
end
|
|
|
|
it "prints out git info" do
|
|
install_gemfile <<-G
|
|
gem "foo", :git => "#{lib_path("foo-1.0")}"
|
|
G
|
|
expect(the_bundle).to include_gems "foo 1.0"
|
|
|
|
bundle :show
|
|
expect(out).to include("foo (1.0 #{@git.ref_for("master", 6)}")
|
|
end
|
|
|
|
it "prints out branch names other than master" do
|
|
update_git "foo", :branch => "omg" do |s|
|
|
s.write "lib/foo.rb", "FOO = '1.0.omg'"
|
|
end
|
|
@revision = revision_for(lib_path("foo-1.0"))[0...6]
|
|
|
|
install_gemfile <<-G
|
|
gem "foo", :git => "#{lib_path("foo-1.0")}", :branch => "omg"
|
|
G
|
|
expect(the_bundle).to include_gems "foo 1.0.omg"
|
|
|
|
bundle :show
|
|
expect(out).to include("foo (1.0 #{@git.ref_for("omg", 6)}")
|
|
end
|
|
|
|
it "doesn't print the branch when tied to a ref" do
|
|
sha = revision_for(lib_path("foo-1.0"))
|
|
install_gemfile <<-G
|
|
gem "foo", :git => "#{lib_path("foo-1.0")}", :ref => "#{sha}"
|
|
G
|
|
|
|
bundle :show
|
|
expect(out).to include("foo (1.0 #{sha[0..6]})")
|
|
end
|
|
|
|
it "handles when a version is a '-' prerelease" do
|
|
@git = build_git("foo", "1.0.0-beta.1", :path => lib_path("foo"))
|
|
install_gemfile <<-G
|
|
gem "foo", "1.0.0-beta.1", :git => "#{lib_path("foo")}"
|
|
G
|
|
expect(the_bundle).to include_gems "foo 1.0.0.pre.beta.1"
|
|
|
|
bundle! :show
|
|
expect(out).to include("foo (1.0.0.pre.beta.1")
|
|
end
|
|
end
|
|
|
|
context "in a fresh gem in a blank git repo" do
|
|
before :each do
|
|
build_git "foo", :path => lib_path("foo")
|
|
in_app_root_custom lib_path("foo")
|
|
File.open("Gemfile", "w") {|f| f.puts "gemspec" }
|
|
sys_exec "rm -rf .git && git init"
|
|
end
|
|
|
|
it "does not output git errors" do
|
|
bundle :show
|
|
expect(err_without_deprecations).to be_empty
|
|
end
|
|
end
|
|
|
|
it "performs an automatic bundle install" do
|
|
gemfile <<-G
|
|
source "#{file_uri_for(gem_repo1)}"
|
|
gem "foo"
|
|
G
|
|
|
|
bundle "config set auto_install 1"
|
|
bundle :show
|
|
expect(out).to include("Installing foo 1.0")
|
|
end
|
|
|
|
context "with a valid regexp for gem name" do
|
|
it "presents alternatives" do
|
|
install_gemfile <<-G
|
|
source "#{file_uri_for(gem_repo1)}"
|
|
gem "rack"
|
|
gem "rack-obama"
|
|
G
|
|
|
|
bundle "show rac"
|
|
expect(out).to eq "1 : rack\n2 : rack-obama\n0 : - exit -\n>"
|
|
end
|
|
end
|
|
|
|
context "with an invalid regexp for gem name" do
|
|
it "does not find the gem" do
|
|
install_gemfile <<-G
|
|
source "#{file_uri_for(gem_repo1)}"
|
|
gem "rails"
|
|
G
|
|
|
|
invalid_regexp = "[]"
|
|
|
|
bundle "show #{invalid_regexp}"
|
|
expect(err).to include("Could not find gem '#{invalid_regexp}'.")
|
|
end
|
|
end
|
|
|
|
context "--outdated option" do
|
|
# Regression test for https://github.com/bundler/bundler/issues/5375
|
|
before do
|
|
build_repo2
|
|
end
|
|
|
|
it "doesn't update gems to newer versions" do
|
|
install_gemfile! <<-G
|
|
source "#{file_uri_for(gem_repo2)}"
|
|
gem "rails"
|
|
G
|
|
|
|
expect(the_bundle).to include_gem("rails 2.3.2")
|
|
|
|
update_repo2 do
|
|
build_gem "rails", "3.0.0" do |s|
|
|
s.executables = "rails"
|
|
end
|
|
end
|
|
|
|
bundle! "show --outdated"
|
|
|
|
bundle! "install"
|
|
expect(the_bundle).to include_gem("rails 2.3.2")
|
|
end
|
|
end
|
|
end
|
|
|
|
RSpec.describe "bundle show", :bundler => "3" do
|
|
pending "shows a friendly error about the command removal"
|
|
end
|