2018-11-02 19:07:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
RSpec.describe "bundle info" do
|
2019-04-14 02:01:35 -04:00
|
|
|
context "with a standard Gemfile" do
|
2018-11-02 19:07:56 -04:00
|
|
|
before do
|
2020-12-08 02:36:29 -05:00
|
|
|
build_repo2 do
|
|
|
|
build_gem "has_metadata" do |s|
|
|
|
|
s.metadata = {
|
2022-09-07 01:13:04 -04:00
|
|
|
"bug_tracker_uri" => "https://example.com/user/bestgemever/issues",
|
|
|
|
"changelog_uri" => "https://example.com/user/bestgemever/CHANGELOG.md",
|
2020-12-08 02:36:29 -05:00
|
|
|
"documentation_uri" => "https://www.example.info/gems/bestgemever/0.0.1",
|
2022-09-07 01:13:04 -04:00
|
|
|
"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",
|
2020-12-08 02:36:29 -05:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-06-03 14:46:03 -04:00
|
|
|
install_gemfile <<-G
|
2020-12-08 02:36:29 -05:00
|
|
|
source "#{file_uri_for(gem_repo2)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gem "rails"
|
2020-05-08 01:19:04 -04:00
|
|
|
gem "has_metadata"
|
2022-01-26 13:35:13 -05:00
|
|
|
gem "thin"
|
2018-11-02 19:07:56 -04:00
|
|
|
G
|
|
|
|
end
|
|
|
|
|
2019-04-14 02:01:35 -04:00
|
|
|
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)
|
2019-04-14 02:01:35 -04:00
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "info rails"
|
2019-04-14 02:01:35 -04:00
|
|
|
|
2020-05-08 01:19:04 -04:00
|
|
|
expect(bundled_app_lock).to exist
|
2019-04-14 02:01:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "prints information if gem exists in bundle" do
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "info rails"
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include "* rails (2.3.2)
|
|
|
|
\tSummary: This is just a fake gem for testing
|
2019-04-14 02:01:35 -04:00
|
|
|
\tHomepage: http://example.com
|
|
|
|
\tPath: #{default_bundle_path("gems", "rails-2.3.2")}"
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
2019-04-14 02:01:35 -04:00
|
|
|
it "prints path if gem exists in bundle" do
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "info rails --path"
|
2019-04-14 02:01:35 -04:00
|
|
|
expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "prints the path to the running bundler" do
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "info bundler --path"
|
2019-04-14 02:01:35 -04:00
|
|
|
expect(out).to eq(root.to_s)
|
|
|
|
end
|
|
|
|
|
2021-12-05 19:42:43 -05:00
|
|
|
it "prints gem version if exists in bundle" do
|
|
|
|
bundle "info rails --version"
|
|
|
|
expect(out).to eq("2.3.2")
|
|
|
|
end
|
|
|
|
|
2021-11-25 15:29:56 -05:00
|
|
|
it "doesn't claim that bundler has been deleted, even if using a custom path without bundler there" do
|
|
|
|
bundle "config set --local path vendor/bundle"
|
|
|
|
bundle "install"
|
|
|
|
bundle "info bundler"
|
|
|
|
expect(out).to include("\tPath: #{root}")
|
|
|
|
expect(err).not_to match(/The gem bundler has been deleted/i)
|
|
|
|
end
|
|
|
|
|
2019-04-14 02:01:35 -04:00
|
|
|
it "complains if gem not in bundle" do
|
2020-06-03 12:43:17 -04:00
|
|
|
bundle "info missing", :raise_on_error => false
|
2019-04-14 02:01:35 -04:00
|
|
|
expect(err).to eq("Could not find gem 'missing'.")
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
2020-04-10 18:20:19 -04:00
|
|
|
it "warns if path no longer exists on disk" do
|
|
|
|
FileUtils.rm_rf(default_bundle_path("gems", "rails-2.3.2"))
|
|
|
|
|
|
|
|
bundle "info rails --path"
|
|
|
|
|
2021-10-09 05:32:44 -04:00
|
|
|
expect(err).to match(/The gem rails has been deleted/i)
|
2020-04-10 18:20:19 -04:00
|
|
|
expect(err).to match(default_bundle_path("gems", "rails-2.3.2").to_s)
|
2021-10-09 05:28:05 -04:00
|
|
|
|
|
|
|
bundle "info rail --path"
|
|
|
|
expect(err).to match(/The gem rails has been deleted/i)
|
|
|
|
expect(err).to match(default_bundle_path("gems", "rails-2.3.2").to_s)
|
2021-10-09 05:29:11 -04:00
|
|
|
|
|
|
|
bundle "info rails"
|
|
|
|
expect(err).to match(/The gem rails has been deleted/i)
|
|
|
|
expect(err).to match(default_bundle_path("gems", "rails-2.3.2").to_s)
|
2020-04-10 18:20:19 -04:00
|
|
|
end
|
|
|
|
|
2020-05-16 06:47:24 -04:00
|
|
|
context "given a default gem shippped in ruby", :ruby_repo do
|
2019-04-14 02:01:35 -04:00
|
|
|
it "prints information about the default gem" do
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "info rdoc"
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include("* rdoc")
|
|
|
|
expect(out).to include("Default Gem: yes")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-05-08 01:19:04 -04:00
|
|
|
context "given a gem with metadata" do
|
|
|
|
it "prints the gem metadata" do
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "info has_metadata"
|
2020-05-08 01:19:04 -04:00
|
|
|
expect(out).to include "* has_metadata (1.0)
|
|
|
|
\tSummary: This is just a fake gem for testing
|
|
|
|
\tHomepage: http://example.com
|
|
|
|
\tDocumentation: https://www.example.info/gems/bestgemever/0.0.1
|
|
|
|
\tSource Code: https://example.com/user/bestgemever
|
|
|
|
\tWiki: https://example.com/user/bestgemever/wiki
|
|
|
|
\tChangelog: https://example.com/user/bestgemever/CHANGELOG.md
|
|
|
|
\tBug Tracker: https://example.com/user/bestgemever/issues
|
|
|
|
\tMailing List: https://groups.example.com/bestgemever
|
|
|
|
\tPath: #{default_bundle_path("gems", "has_metadata-1.0")}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-02 19:07:56 -04:00
|
|
|
context "when gem does not have homepage" do
|
|
|
|
before do
|
2019-04-14 02:01:35 -04:00
|
|
|
build_repo2 do
|
2018-11-02 19:07:56 -04:00
|
|
|
build_gem "rails", "2.3.2" do |s|
|
|
|
|
s.executables = "rails"
|
|
|
|
s.summary = "Just another test gem"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "excludes the homepage field from the output" do
|
|
|
|
expect(out).to_not include("Homepage:")
|
|
|
|
end
|
|
|
|
end
|
2022-01-26 13:35:13 -05:00
|
|
|
|
|
|
|
context "when gem has a reverse dependency on any version" do
|
|
|
|
it "prints the details" do
|
|
|
|
bundle "info rack"
|
|
|
|
|
|
|
|
expect(out).to include("Reverse Dependencies: \n\t\tthin (1.0) depends on rack (>= 0)")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when gem has a reverse dependency on a specific version" do
|
|
|
|
it "prints the details" do
|
|
|
|
bundle "info actionpack"
|
|
|
|
|
|
|
|
expect(out).to include("Reverse Dependencies: \n\t\trails (2.3.2) depends on actionpack (= 2.3.2)")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when gem has no reverse dependencies" do
|
|
|
|
it "excludes the reverse dependencies field from the output" do
|
|
|
|
bundle "info rails"
|
|
|
|
|
|
|
|
expect(out).not_to include("Reverse Dependencies:")
|
|
|
|
end
|
|
|
|
end
|
2019-04-14 02:01:35 -04:00
|
|
|
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
|
2021-07-24 11:27:02 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2019-04-14 02:01:35 -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 "info foo"
|
2022-07-25 12:22:56 -04:00
|
|
|
expect(out).to include("foo (1.0 #{@git.ref_for("main", 6)}")
|
2019-04-14 02:01:35 -04:00
|
|
|
end
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2022-07-25 12:22:56 -04:00
|
|
|
it "prints out branch names other than main" do
|
2019-04-14 02:01:35 -04:00
|
|
|
update_git "foo", :branch => "omg" do |s|
|
|
|
|
s.write "lib/foo.rb", "FOO = '1.0.omg'"
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
2019-04-14 02:01:35 -04:00
|
|
|
@revision = revision_for(lib_path("foo-1.0"))[0...6]
|
|
|
|
|
2020-06-03 14:46:03 -04:00
|
|
|
install_gemfile <<-G
|
2021-07-24 11:27:02 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2019-04-14 02:01:35 -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 "info foo"
|
2019-04-14 02:01:35 -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
|
2021-07-24 11:27:02 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2019-04-14 02:01:35 -04:00
|
|
|
gem "foo", :git => "#{lib_path("foo-1.0")}", :ref => "#{sha}"
|
|
|
|
G
|
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "info foo"
|
2019-04-14 02:01:35 -04:00
|
|
|
expect(out).to include("foo (1.0 #{sha[0..6]})")
|
|
|
|
end
|
|
|
|
|
2019-07-11 05:31:19 -04:00
|
|
|
it "handles when a version is a '-' prerelease" do
|
2019-04-14 02:01:35 -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
|
2021-07-24 11:27:02 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2019-04-14 02:01:35 -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 "info foo"
|
2019-04-14 02:01:35 -04:00
|
|
|
expect(out).to include("foo (1.0.0.pre.beta.1")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
Fix some bundler specs (#2380)
* 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
2019-08-19 20:46:31 -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 "info rac"
|
2021-02-03 00:38:31 -05:00
|
|
|
expect(out).to match(/\A1 : rack\n2 : rack-obama\n0 : - exit -(\n>)?\z/)
|
2019-04-14 02:01:35 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
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)}"
|
2019-04-14 02:01:35 -04:00
|
|
|
gem "rails"
|
|
|
|
G
|
|
|
|
|
|
|
|
invalid_regexp = "[]"
|
|
|
|
|
2020-06-03 12:43:17 -04:00
|
|
|
bundle "info #{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
|
2021-04-14 23:47:04 -04:00
|
|
|
|
|
|
|
context "with without configured" do
|
|
|
|
it "does not find the gem, but gives a helpful error" do
|
|
|
|
bundle "config without test"
|
|
|
|
|
|
|
|
install_gemfile <<-G
|
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
|
|
|
gem "rails", group: :test
|
|
|
|
G
|
|
|
|
|
|
|
|
bundle "info rails", :raise_on_error => false
|
|
|
|
expect(err).to include("Could not find gem 'rails', because it's in the group 'test', configured to be ignored.")
|
|
|
|
end
|
|
|
|
end
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|