2018-11-02 19:07:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
RSpec.describe "post bundle message" do
|
|
|
|
before :each 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 "rack"
|
|
|
|
gem "activesupport", "2.3.5", :group => [:emo, :test]
|
|
|
|
group :test do
|
|
|
|
gem "rspec"
|
|
|
|
end
|
|
|
|
gem "rack-obama", :group => :obama
|
|
|
|
G
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:bundle_path) { "./.bundle" }
|
|
|
|
let(:bundle_show_system_message) { "Use `bundle info [gemname]` to see where a bundled gem is installed." }
|
|
|
|
let(:bundle_show_path_message) { "Bundled gems are installed into `#{bundle_path}`" }
|
|
|
|
let(:bundle_complete_message) { "Bundle complete!" }
|
|
|
|
let(:bundle_updated_message) { "Bundle updated!" }
|
|
|
|
let(:installed_gems_stats) { "4 Gemfile dependencies, 5 gems now installed." }
|
2019-01-04 08:10:58 -05:00
|
|
|
let(:bundle_show_message) { Bundler::VERSION.split(".").first.to_i < 3 ? bundle_show_system_message : bundle_show_path_message }
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
describe "for fresh bundle install" do
|
2020-05-29 06:27:15 -04:00
|
|
|
it "shows proper messages according to the configured groups" do
|
2018-11-02 19:07:56 -04:00
|
|
|
bundle :install
|
|
|
|
expect(out).to include(bundle_show_message)
|
|
|
|
expect(out).not_to include("Gems in the group")
|
|
|
|
expect(out).to include(bundle_complete_message)
|
|
|
|
expect(out).to include(installed_gems_stats)
|
|
|
|
|
2021-01-03 20:11:34 -05:00
|
|
|
bundle "config set --local without emo"
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include(bundle_show_message)
|
2021-04-14 23:47:04 -04:00
|
|
|
expect(out).to include("Gems in the group 'emo' were not installed")
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include(bundle_complete_message)
|
|
|
|
expect(out).to include(installed_gems_stats)
|
|
|
|
|
2021-01-03 20:11:34 -05:00
|
|
|
bundle "config set --local without emo test"
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include(bundle_show_message)
|
2021-04-14 23:47:04 -04:00
|
|
|
expect(out).to include("Gems in the groups 'emo' and 'test' were not installed")
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include(bundle_complete_message)
|
|
|
|
expect(out).to include("4 Gemfile dependencies, 3 gems now installed.")
|
|
|
|
|
2021-01-03 20:11:34 -05:00
|
|
|
bundle "config set --local without emo obama test"
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include(bundle_show_message)
|
2021-04-14 23:47:04 -04:00
|
|
|
expect(out).to include("Gems in the groups 'emo', 'obama' and 'test' were not installed")
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include(bundle_complete_message)
|
|
|
|
expect(out).to include("4 Gemfile dependencies, 2 gems now installed.")
|
|
|
|
end
|
|
|
|
|
2020-05-29 06:27:15 -04:00
|
|
|
describe "with `path` configured" do
|
2018-11-02 19:07:56 -04:00
|
|
|
let(:bundle_path) { "./vendor" }
|
|
|
|
|
2020-05-29 06:27:15 -04:00
|
|
|
it "shows proper messages according to the configured groups" do
|
2021-01-03 20:11:34 -05:00
|
|
|
bundle "config set --local path vendor"
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include(bundle_show_path_message)
|
|
|
|
expect(out).to_not include("Gems in the group")
|
|
|
|
expect(out).to include(bundle_complete_message)
|
|
|
|
|
2021-01-03 20:11:34 -05:00
|
|
|
bundle "config set --local path vendor"
|
|
|
|
bundle "config set --local without emo"
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include(bundle_show_path_message)
|
2021-04-14 23:47:04 -04:00
|
|
|
expect(out).to include("Gems in the group 'emo' were not installed")
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include(bundle_complete_message)
|
|
|
|
|
2021-01-03 20:11:34 -05:00
|
|
|
bundle "config set --local path vendor"
|
|
|
|
bundle "config set --local without emo test"
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include(bundle_show_path_message)
|
2021-04-14 23:47:04 -04:00
|
|
|
expect(out).to include("Gems in the groups 'emo' and 'test' were not installed")
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include(bundle_complete_message)
|
|
|
|
|
2021-01-03 20:11:34 -05:00
|
|
|
bundle "config set --local path vendor"
|
|
|
|
bundle "config set --local without emo obama test"
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include(bundle_show_path_message)
|
2021-04-14 23:47:04 -04:00
|
|
|
expect(out).to include("Gems in the groups 'emo', 'obama' and 'test' were not installed")
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include(bundle_complete_message)
|
|
|
|
end
|
2020-05-29 06:27:15 -04:00
|
|
|
end
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2020-05-29 06:27:15 -04:00
|
|
|
describe "with an absolute `path` inside the cwd configured" do
|
2020-05-29 06:46:16 -04:00
|
|
|
let(:bundle_path) { bundled_app("cache") }
|
|
|
|
|
2020-05-29 06:27:15 -04:00
|
|
|
it "shows proper messages according to the configured groups" do
|
2021-01-03 20:11:34 -05:00
|
|
|
bundle "config set --local path #{bundle_path}"
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include("Bundled gems are installed into `./cache`")
|
|
|
|
expect(out).to_not include("Gems in the group")
|
|
|
|
expect(out).to include(bundle_complete_message)
|
|
|
|
end
|
2020-05-29 06:27:15 -04:00
|
|
|
end
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2020-05-29 06:27:15 -04:00
|
|
|
describe "with `path` configured to an absolute path outside the cwd" do
|
2020-05-29 06:46:16 -04:00
|
|
|
let(:bundle_path) { tmp("not_bundled_app") }
|
|
|
|
|
2020-05-29 06:27:15 -04:00
|
|
|
it "shows proper messages according to the configured groups" do
|
2021-01-03 20:11:34 -05:00
|
|
|
bundle "config set --local path #{bundle_path}"
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include("Bundled gems are installed into `#{tmp("not_bundled_app")}`")
|
|
|
|
expect(out).to_not include("Gems in the group")
|
|
|
|
expect(out).to include(bundle_complete_message)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "with misspelled or non-existent gem name" do
|
2019-07-23 07:11:33 -04:00
|
|
|
before do
|
|
|
|
bundle "config set force_ruby_platform true"
|
|
|
|
end
|
|
|
|
|
2021-02-01 10:17:16 -05:00
|
|
|
it "should report a helpful error message" do
|
2020-06-03 12:43:17 -04:00
|
|
|
install_gemfile <<-G, :raise_on_error => false
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gem "rack"
|
|
|
|
gem "not-a-gem", :group => :development
|
|
|
|
G
|
2019-05-06 12:06:21 -04:00
|
|
|
expect(err).to include <<-EOS.strip
|
|
|
|
Could not find gem 'not-a-gem' in rubygems repository #{file_uri_for(gem_repo1)}/ or installed locally.
|
2018-11-02 19:07:56 -04:00
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should report a helpful error message with reference to cache if available" do
|
|
|
|
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 "rack"
|
|
|
|
G
|
|
|
|
bundle :cache
|
|
|
|
expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
|
2020-06-03 12:43:17 -04:00
|
|
|
install_gemfile <<-G, :raise_on_error => false
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gem "rack"
|
|
|
|
gem "not-a-gem", :group => :development
|
|
|
|
G
|
2019-04-14 02:01:35 -04:00
|
|
|
expect(err).to include("Could not find gem 'not-a-gem' in").
|
2018-11-02 19:07:56 -04:00
|
|
|
and include("or in gems cached in vendor/cache.")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-05-29 06:46:16 -04:00
|
|
|
describe "for second bundle install run", :bundler => "< 3" do
|
2018-11-02 19:07:56 -04:00
|
|
|
it "without any options" do
|
|
|
|
2.times { bundle :install }
|
|
|
|
expect(out).to include(bundle_show_message)
|
|
|
|
expect(out).to_not include("Gems in the groups")
|
|
|
|
expect(out).to include(bundle_complete_message)
|
|
|
|
expect(out).to include(installed_gems_stats)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "with --without one group" do
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "install --without emo"
|
|
|
|
bundle :install
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include(bundle_show_message)
|
2021-04-14 23:47:04 -04:00
|
|
|
expect(out).to include("Gems in the group 'emo' were not installed")
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include(bundle_complete_message)
|
|
|
|
expect(out).to include(installed_gems_stats)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "with --without two groups" do
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "install --without emo test"
|
|
|
|
bundle :install
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include(bundle_show_message)
|
2021-04-14 23:47:04 -04:00
|
|
|
expect(out).to include("Gems in the groups 'emo' and 'test' were not installed")
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include(bundle_complete_message)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "with --without more groups" do
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "install --without emo obama test"
|
2018-11-02 19:07:56 -04:00
|
|
|
bundle :install
|
|
|
|
expect(out).to include(bundle_show_message)
|
2021-04-14 23:47:04 -04:00
|
|
|
expect(out).to include("Gems in the groups 'emo', 'obama' and 'test' were not installed")
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include(bundle_complete_message)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "for bundle update" do
|
2020-05-29 06:27:15 -04:00
|
|
|
it "shows proper messages according to the configured groups" do
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :update, :all => true
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).not_to include("Gems in the groups")
|
|
|
|
expect(out).to include(bundle_updated_message)
|
|
|
|
|
2021-01-03 20:11:34 -05:00
|
|
|
bundle "config set --local without emo"
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install
|
|
|
|
bundle :update, :all => true
|
2021-04-14 23:47:04 -04:00
|
|
|
expect(out).to include("Gems in the group 'emo' were not updated")
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include(bundle_updated_message)
|
|
|
|
|
2021-01-03 20:11:34 -05:00
|
|
|
bundle "config set --local without emo test"
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install
|
|
|
|
bundle :update, :all => true
|
2021-04-14 23:47:04 -04:00
|
|
|
expect(out).to include("Gems in the groups 'emo' and 'test' were not updated")
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include(bundle_updated_message)
|
|
|
|
|
2021-01-03 20:11:34 -05:00
|
|
|
bundle "config set --local without emo obama test"
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install
|
|
|
|
bundle :update, :all => true
|
2021-04-14 23:47:04 -04:00
|
|
|
expect(out).to include("Gems in the groups 'emo', 'obama' and 'test' were not updated")
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include(bundle_updated_message)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|