2018-11-03 02:07:56 +03:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
RSpec.describe "bundle help" do
|
2020-10-15 07:20:25 +03:00
|
|
|
it "uses man when available" do
|
2018-11-03 02:07:56 +03:00
|
|
|
with_fake_man do
|
|
|
|
bundle "help gemfile"
|
|
|
|
end
|
2021-01-04 04:11:34 +03:00
|
|
|
expect(out).to eq(%(["#{man_dir}/gemfile.5"]))
|
2018-11-03 02:07:56 +03:00
|
|
|
end
|
|
|
|
|
2020-10-15 07:20:25 +03:00
|
|
|
it "prefixes bundle commands with bundle- when finding the man files" do
|
2018-11-03 02:07:56 +03:00
|
|
|
with_fake_man do
|
|
|
|
bundle "help install"
|
|
|
|
end
|
2021-01-04 04:11:34 +03:00
|
|
|
expect(out).to eq(%(["#{man_dir}/bundle-install.1"]))
|
2018-11-03 02:07:56 +03:00
|
|
|
end
|
|
|
|
|
2020-10-15 07:20:25 +03:00
|
|
|
it "simply outputs the human readable file when there is no man on the path" do
|
2018-11-03 02:07:56 +03:00
|
|
|
with_path_as("") do
|
|
|
|
bundle "help install"
|
|
|
|
end
|
2020-10-15 07:20:25 +03:00
|
|
|
expect(out).to match(/bundle-install/)
|
2018-11-03 02:07:56 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
it "still outputs the old help for commands that do not have man pages yet" do
|
2022-09-07 08:13:04 +03:00
|
|
|
bundle "help fund"
|
|
|
|
expect(out).to include("Lists information about gems seeking funding assistance")
|
2018-11-03 02:07:56 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
it "looks for a binary and executes it with --help option if it's named bundler-<task>" do
|
2020-06-14 20:42:31 +03:00
|
|
|
skip "Could not find command testtasks, probably because not a windows friendly executable" if Gem.win_platform?
|
2020-05-08 08:19:04 +03:00
|
|
|
|
2018-11-03 02:07:56 +03:00
|
|
|
File.open(tmp("bundler-testtasks"), "w", 0o755) do |f|
|
|
|
|
f.puts "#!/usr/bin/env ruby\nputs ARGV.join(' ')\n"
|
|
|
|
end
|
|
|
|
|
|
|
|
with_path_added(tmp) do
|
|
|
|
bundle "help testtasks"
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(out).to eq("--help")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "is called when the --help flag is used after the command" do
|
|
|
|
with_fake_man do
|
|
|
|
bundle "install --help"
|
|
|
|
end
|
2021-01-04 04:11:34 +03:00
|
|
|
expect(out).to eq(%(["#{man_dir}/bundle-install.1"]))
|
2018-11-03 02:07:56 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
it "is called when the --help flag is used before the command" do
|
|
|
|
with_fake_man do
|
|
|
|
bundle "--help install"
|
|
|
|
end
|
2021-01-04 04:11:34 +03:00
|
|
|
expect(out).to eq(%(["#{man_dir}/bundle-install.1"]))
|
2018-11-03 02:07:56 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
it "is called when the -h flag is used before the command" do
|
|
|
|
with_fake_man do
|
|
|
|
bundle "-h install"
|
|
|
|
end
|
2021-01-04 04:11:34 +03:00
|
|
|
expect(out).to eq(%(["#{man_dir}/bundle-install.1"]))
|
2018-11-03 02:07:56 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
it "is called when the -h flag is used after the command" do
|
|
|
|
with_fake_man do
|
|
|
|
bundle "install -h"
|
|
|
|
end
|
2021-01-04 04:11:34 +03:00
|
|
|
expect(out).to eq(%(["#{man_dir}/bundle-install.1"]))
|
2018-11-03 02:07:56 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
it "has helpful output when using --help flag for a non-existent command" do
|
|
|
|
with_fake_man do
|
2020-06-03 19:43:17 +03:00
|
|
|
bundle "instill -h", :raise_on_error => false
|
2018-11-03 02:07:56 +03:00
|
|
|
end
|
2019-04-14 09:01:35 +03:00
|
|
|
expect(err).to include('Could not find command "instill".')
|
2018-11-03 02:07:56 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
it "is called when only using the --help flag" do
|
|
|
|
with_fake_man do
|
|
|
|
bundle "--help"
|
|
|
|
end
|
2021-01-04 04:11:34 +03:00
|
|
|
expect(out).to eq(%(["#{man_dir}/bundle.1"]))
|
2018-11-03 02:07:56 +03:00
|
|
|
|
|
|
|
with_fake_man do
|
|
|
|
bundle "-h"
|
|
|
|
end
|
2021-01-04 04:11:34 +03:00
|
|
|
expect(out).to eq(%(["#{man_dir}/bundle.1"]))
|
2018-11-03 02:07:56 +03:00
|
|
|
end
|
|
|
|
end
|