2018-11-02 19:07:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-04-14 02:01:35 -04:00
|
|
|
RSpec.describe "bundle show", :bundler => "< 3" do
|
2018-11-02 19:07:56 -04:00
|
|
|
context "with a standard Gemfile" do
|
|
|
|
before :each do
|
2020-06-03 14:46:03 -04:00
|
|
|
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 "rails"
|
|
|
|
G
|
|
|
|
end
|
|
|
|
|
|
|
|
it "creates a Gemfile.lock if one did not exist" do
|
2020-05-08 01:19:04 -04:00
|
|
|
FileUtils.rm(bundled_app_lock)
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "show"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2020-05-08 01:19:04 -04:00
|
|
|
expect(bundled_app_lock).to exist
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "creates a Gemfile.lock when invoked with a gem name" do
|
2020-05-08 01:19:04 -04:00
|
|
|
FileUtils.rm(bundled_app_lock)
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "show rails"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2020-05-08 01:19:04 -04:00
|
|
|
expect(bundled_app_lock).to exist
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "prints path if gem exists in bundle" do
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "show rails"
|
2018-11-02 19:07:56 -04:00
|
|
|
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
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "show rails --paths"
|
2018-11-02 19:07:56 -04:00
|
|
|
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"
|
|
|
|
|
2019-04-14 02:01:35 -04:00
|
|
|
expect(err).to match(/has been deleted/i)
|
|
|
|
expect(err).to match(default_bundle_path("gems", "rails-2.3.2").to_s)
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "prints the path to the running bundler" do
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "show bundler"
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to eq(root.to_s)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "complains if gem not in bundle" do
|
2020-06-03 12:43:17 -04:00
|
|
|
bundle "show missing", :raise_on_error => false
|
2019-04-14 02:01:35 -04:00
|
|
|
expect(err).to match(/could not find gem 'missing'/i)
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "prints path of all gems in bundle sorted by name" do
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "show --paths"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2020-05-08 01:19:04 -04:00
|
|
|
expect(out).to include(default_bundle_path("gems", "rake-13.0.1").to_s)
|
2018-11-02 19:07:56 -04:00
|
|
|
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
|
|
|
|
|
2019-06-01 05:49:40 -04:00
|
|
|
it "prints summary of gems" do
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "show --verbose"
|
2019-04-14 02:01:35 -04:00
|
|
|
|
2019-06-01 05:49:40 -04:00
|
|
|
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
|
2019-04-14 02:01:35 -04:00
|
|
|
end
|
|
|
|
|
2019-06-01 05:49:40 -04:00
|
|
|
it "includes bundler in the summary of gems" do
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "show --verbose"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-06-01 05:49:40 -04:00
|
|
|
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
|
2018-11-02 19:07:56 -04:00
|
|
|
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
|
2020-06-03 14:46:03 -04:00
|
|
|
install_gemfile <<-G
|
2018-11-02 19:07:56 -04:00
|
|
|
gem "foo", :git => "#{lib_path("foo-1.0")}"
|
|
|
|
G
|
|
|
|
expect(the_bundle).to include_gems "foo 1.0"
|
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :show
|
2018-11-02 19:07:56 -04:00
|
|
|
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]
|
|
|
|
|
2020-06-03 14:46:03 -04:00
|
|
|
install_gemfile <<-G
|
2018-11-02 19:07:56 -04:00
|
|
|
gem "foo", :git => "#{lib_path("foo-1.0")}", :branch => "omg"
|
|
|
|
G
|
|
|
|
expect(the_bundle).to include_gems "foo 1.0.omg"
|
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :show
|
2018-11-02 19:07:56 -04:00
|
|
|
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"))
|
2020-06-03 14:46:03 -04:00
|
|
|
install_gemfile <<-G
|
2018-11-02 19:07:56 -04:00
|
|
|
gem "foo", :git => "#{lib_path("foo-1.0")}", :ref => "#{sha}"
|
|
|
|
G
|
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :show
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include("foo (1.0 #{sha[0..6]})")
|
|
|
|
end
|
|
|
|
|
2019-04-14 02:01:35 -04:00
|
|
|
it "handles when a version is a '-' prerelease" do
|
2018-11-02 19:07:56 -04:00
|
|
|
@git = build_git("foo", "1.0.0-beta.1", :path => lib_path("foo"))
|
2020-06-03 14:46:03 -04:00
|
|
|
install_gemfile <<-G
|
2018-11-02 19:07:56 -04:00
|
|
|
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"
|
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :show
|
2018-11-02 19:07:56 -04:00
|
|
|
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")
|
2020-05-08 01:19:04 -04:00
|
|
|
File.open(lib_path("foo/Gemfile"), "w") {|f| f.puts "gemspec" }
|
|
|
|
sys_exec "rm -rf .git && git init", :dir => lib_path("foo")
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "does not output git errors" do
|
2020-05-08 01:19:04 -04:00
|
|
|
bundle :show, :dir => lib_path("foo")
|
2019-04-14 02:01:35 -04:00
|
|
|
expect(err_without_deprecations).to be_empty
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "performs an automatic bundle install" do
|
|
|
|
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"
|
|
|
|
G
|
|
|
|
|
2019-04-14 02:01:35 -04:00
|
|
|
bundle "config set auto_install 1"
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :show
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include("Installing foo 1.0")
|
|
|
|
end
|
|
|
|
|
2019-04-14 02:01:35 -04:00
|
|
|
context "with a valid regexp for gem name" do
|
2020-05-08 01:19:04 -04:00
|
|
|
it "presents alternatives", :readline do
|
2020-06-03 14:46:03 -04:00
|
|
|
install_gemfile <<-G
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2019-04-14 02:01:35 -04:00
|
|
|
gem "rack"
|
|
|
|
gem "rack-obama"
|
|
|
|
G
|
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "show rac"
|
2019-04-14 02:01:35 -04:00
|
|
|
expect(out).to eq "1 : rack\n2 : rack-obama\n0 : - exit -\n>"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-02 19:07:56 -04:00
|
|
|
context "with an invalid regexp for gem name" do
|
|
|
|
it "does not find the gem" do
|
2020-06-03 14:46:03 -04:00
|
|
|
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 "rails"
|
|
|
|
G
|
|
|
|
|
|
|
|
invalid_regexp = "[]"
|
|
|
|
|
2020-06-03 12:43:17 -04:00
|
|
|
bundle "show #{invalid_regexp}", :raise_on_error => false
|
2019-04-14 02:01:35 -04:00
|
|
|
expect(err).to include("Could not find gem '#{invalid_regexp}'.")
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "--outdated option" do
|
2020-05-08 01:19:04 -04:00
|
|
|
# Regression test for https://github.com/rubygems/bundler/issues/5375
|
2018-11-02 19:07:56 -04:00
|
|
|
before do
|
|
|
|
build_repo2
|
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't update gems to newer versions" do
|
2020-06-03 14:46:03 -04:00
|
|
|
install_gemfile <<-G
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo2)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
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
|
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "show --outdated"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "install"
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(the_bundle).to include_gem("rails 2.3.2")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-04-14 02:01:35 -04:00
|
|
|
|
|
|
|
RSpec.describe "bundle show", :bundler => "3" do
|
|
|
|
pending "shows a friendly error about the command removal"
|
|
|
|
end
|