From 2867fae68d71ab8c0e0e70fe3d128a5fe6b57278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Sun, 28 Apr 2019 15:05:36 +0200 Subject: Move spec to a better location Since it includes stuff for `bundle update` too. --- spec/commands/post_bundle_message_spec.rb | 206 ++++++++++++++++++++++++++++++ spec/install/post_bundle_message_spec.rb | 206 ------------------------------ 2 files changed, 206 insertions(+), 206 deletions(-) create mode 100644 spec/commands/post_bundle_message_spec.rb delete mode 100644 spec/install/post_bundle_message_spec.rb diff --git a/spec/commands/post_bundle_message_spec.rb b/spec/commands/post_bundle_message_spec.rb new file mode 100644 index 0000000000..1efd0b8146 --- /dev/null +++ b/spec/commands/post_bundle_message_spec.rb @@ -0,0 +1,206 @@ +# frozen_string_literal: true + +RSpec.describe "post bundle message" do + before :each do + gemfile <<-G + source "file://#{gem_repo1}" + 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." } + let(:bundle_show_message) { Bundler::VERSION.split(".").first.to_i < 3 ? bundle_show_system_message : bundle_show_path_message } + + describe "for fresh bundle install" do + it "without any options" do + 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) + end + + it "with --without one group" do + bundle! :install, forgotten_command_line_options(:without => "emo") + expect(out).to include(bundle_show_message) + expect(out).to include("Gems in the group emo were not installed") + expect(out).to include(bundle_complete_message) + expect(out).to include(installed_gems_stats) + end + + it "with --without two groups" do + bundle! :install, forgotten_command_line_options(:without => "emo test") + expect(out).to include(bundle_show_message) + expect(out).to include("Gems in the groups emo and test were not installed") + expect(out).to include(bundle_complete_message) + expect(out).to include("4 Gemfile dependencies, 3 gems now installed.") + end + + it "with --without more groups" do + bundle! :install, forgotten_command_line_options(:without => "emo obama test") + expect(out).to include(bundle_show_message) + expect(out).to include("Gems in the groups emo, obama and test were not installed") + expect(out).to include(bundle_complete_message) + expect(out).to include("4 Gemfile dependencies, 2 gems now installed.") + end + + describe "with --path and" do + let(:bundle_path) { "./vendor" } + + it "without any options" do + bundle! :install, forgotten_command_line_options(:path => "vendor") + expect(out).to include(bundle_show_path_message) + expect(out).to_not include("Gems in the group") + expect(out).to include(bundle_complete_message) + end + + it "with --without one group" do + bundle! :install, forgotten_command_line_options(:without => "emo", :path => "vendor") + expect(out).to include(bundle_show_path_message) + expect(out).to include("Gems in the group emo were not installed") + expect(out).to include(bundle_complete_message) + end + + it "with --without two groups" do + bundle! :install, forgotten_command_line_options(:without => "emo test", :path => "vendor") + expect(out).to include(bundle_show_path_message) + expect(out).to include("Gems in the groups emo and test were not installed") + expect(out).to include(bundle_complete_message) + end + + it "with --without more groups" do + bundle! :install, forgotten_command_line_options(:without => "emo obama test", :path => "vendor") + expect(out).to include(bundle_show_path_message) + expect(out).to include("Gems in the groups emo, obama and test were not installed") + expect(out).to include(bundle_complete_message) + end + + it "with an absolute --path inside the cwd" do + bundle! :install, forgotten_command_line_options(:path => bundled_app("cache")) + 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 + + it "with an absolute --path outside the cwd" do + bundle! :install, forgotten_command_line_options(:path => tmp("not_bundled_app")) + 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 + it "should report a helpful error message", :bundler => "< 3" do + install_gemfile <<-G + source "file://localhost#{gem_repo1}" + gem "rack" + gem "not-a-gem", :group => :development + G + expect(err).to include("Could not find gem 'not-a-gem' in any of the gem sources listed in your Gemfile.") + end + + it "should report a helpful error message", :bundler => "3" do + install_gemfile <<-G + source "file://localhost#{gem_repo1}" + gem "rack" + gem "not-a-gem", :group => :development + G + expect(err).to include normalize_uri_file(<<-EOS.strip) +Could not find gem 'not-a-gem' in rubygems repository file://localhost#{gem_repo1}/ or installed locally. +The source does not contain any versions of 'not-a-gem' + EOS + end + + it "should report a helpful error message with reference to cache if available" do + install_gemfile <<-G + source "file://localhost#{gem_repo1}" + gem "rack" + G + bundle :cache + expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist + install_gemfile <<-G + source "file://localhost#{gem_repo1}" + gem "rack" + gem "not-a-gem", :group => :development + G + expect(err).to include("Could not find gem 'not-a-gem' in"). + and include("or in gems cached in vendor/cache.") + end + end + end + + describe "for second bundle install run" do + 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 + bundle! :install, forgotten_command_line_options(:without => "emo") + bundle! :install + expect(out).to include(bundle_show_message) + expect(out).to include("Gems in the group emo were not installed") + expect(out).to include(bundle_complete_message) + expect(out).to include(installed_gems_stats) + end + + it "with --without two groups" do + bundle! :install, forgotten_command_line_options(:without => "emo test") + bundle! :install + expect(out).to include(bundle_show_message) + expect(out).to include("Gems in the groups emo and test were not installed") + expect(out).to include(bundle_complete_message) + end + + it "with --without more groups" do + bundle! :install, forgotten_command_line_options(:without => "emo obama test") + bundle :install + expect(out).to include(bundle_show_message) + expect(out).to include("Gems in the groups emo, obama and test were not installed") + expect(out).to include(bundle_complete_message) + end + end + + describe "for bundle update" do + it "without any options" do + bundle! :update, :all => true + expect(out).not_to include("Gems in the groups") + expect(out).to include(bundle_updated_message) + end + + it "with --without one group" do + bundle! :install, forgotten_command_line_options(:without => "emo") + bundle! :update, :all => true + expect(out).to include("Gems in the group emo were not installed") + expect(out).to include(bundle_updated_message) + end + + it "with --without two groups" do + bundle! :install, forgotten_command_line_options(:without => "emo test") + bundle! :update, :all => true + expect(out).to include("Gems in the groups emo and test were not installed") + expect(out).to include(bundle_updated_message) + end + + it "with --without more groups" do + bundle! :install, forgotten_command_line_options(:without => "emo obama test") + bundle! :update, :all => true + expect(out).to include("Gems in the groups emo, obama and test were not installed") + expect(out).to include(bundle_updated_message) + end + end +end diff --git a/spec/install/post_bundle_message_spec.rb b/spec/install/post_bundle_message_spec.rb deleted file mode 100644 index 1efd0b8146..0000000000 --- a/spec/install/post_bundle_message_spec.rb +++ /dev/null @@ -1,206 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe "post bundle message" do - before :each do - gemfile <<-G - source "file://#{gem_repo1}" - 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." } - let(:bundle_show_message) { Bundler::VERSION.split(".").first.to_i < 3 ? bundle_show_system_message : bundle_show_path_message } - - describe "for fresh bundle install" do - it "without any options" do - 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) - end - - it "with --without one group" do - bundle! :install, forgotten_command_line_options(:without => "emo") - expect(out).to include(bundle_show_message) - expect(out).to include("Gems in the group emo were not installed") - expect(out).to include(bundle_complete_message) - expect(out).to include(installed_gems_stats) - end - - it "with --without two groups" do - bundle! :install, forgotten_command_line_options(:without => "emo test") - expect(out).to include(bundle_show_message) - expect(out).to include("Gems in the groups emo and test were not installed") - expect(out).to include(bundle_complete_message) - expect(out).to include("4 Gemfile dependencies, 3 gems now installed.") - end - - it "with --without more groups" do - bundle! :install, forgotten_command_line_options(:without => "emo obama test") - expect(out).to include(bundle_show_message) - expect(out).to include("Gems in the groups emo, obama and test were not installed") - expect(out).to include(bundle_complete_message) - expect(out).to include("4 Gemfile dependencies, 2 gems now installed.") - end - - describe "with --path and" do - let(:bundle_path) { "./vendor" } - - it "without any options" do - bundle! :install, forgotten_command_line_options(:path => "vendor") - expect(out).to include(bundle_show_path_message) - expect(out).to_not include("Gems in the group") - expect(out).to include(bundle_complete_message) - end - - it "with --without one group" do - bundle! :install, forgotten_command_line_options(:without => "emo", :path => "vendor") - expect(out).to include(bundle_show_path_message) - expect(out).to include("Gems in the group emo were not installed") - expect(out).to include(bundle_complete_message) - end - - it "with --without two groups" do - bundle! :install, forgotten_command_line_options(:without => "emo test", :path => "vendor") - expect(out).to include(bundle_show_path_message) - expect(out).to include("Gems in the groups emo and test were not installed") - expect(out).to include(bundle_complete_message) - end - - it "with --without more groups" do - bundle! :install, forgotten_command_line_options(:without => "emo obama test", :path => "vendor") - expect(out).to include(bundle_show_path_message) - expect(out).to include("Gems in the groups emo, obama and test were not installed") - expect(out).to include(bundle_complete_message) - end - - it "with an absolute --path inside the cwd" do - bundle! :install, forgotten_command_line_options(:path => bundled_app("cache")) - 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 - - it "with an absolute --path outside the cwd" do - bundle! :install, forgotten_command_line_options(:path => tmp("not_bundled_app")) - 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 - it "should report a helpful error message", :bundler => "< 3" do - install_gemfile <<-G - source "file://localhost#{gem_repo1}" - gem "rack" - gem "not-a-gem", :group => :development - G - expect(err).to include("Could not find gem 'not-a-gem' in any of the gem sources listed in your Gemfile.") - end - - it "should report a helpful error message", :bundler => "3" do - install_gemfile <<-G - source "file://localhost#{gem_repo1}" - gem "rack" - gem "not-a-gem", :group => :development - G - expect(err).to include normalize_uri_file(<<-EOS.strip) -Could not find gem 'not-a-gem' in rubygems repository file://localhost#{gem_repo1}/ or installed locally. -The source does not contain any versions of 'not-a-gem' - EOS - end - - it "should report a helpful error message with reference to cache if available" do - install_gemfile <<-G - source "file://localhost#{gem_repo1}" - gem "rack" - G - bundle :cache - expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist - install_gemfile <<-G - source "file://localhost#{gem_repo1}" - gem "rack" - gem "not-a-gem", :group => :development - G - expect(err).to include("Could not find gem 'not-a-gem' in"). - and include("or in gems cached in vendor/cache.") - end - end - end - - describe "for second bundle install run" do - 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 - bundle! :install, forgotten_command_line_options(:without => "emo") - bundle! :install - expect(out).to include(bundle_show_message) - expect(out).to include("Gems in the group emo were not installed") - expect(out).to include(bundle_complete_message) - expect(out).to include(installed_gems_stats) - end - - it "with --without two groups" do - bundle! :install, forgotten_command_line_options(:without => "emo test") - bundle! :install - expect(out).to include(bundle_show_message) - expect(out).to include("Gems in the groups emo and test were not installed") - expect(out).to include(bundle_complete_message) - end - - it "with --without more groups" do - bundle! :install, forgotten_command_line_options(:without => "emo obama test") - bundle :install - expect(out).to include(bundle_show_message) - expect(out).to include("Gems in the groups emo, obama and test were not installed") - expect(out).to include(bundle_complete_message) - end - end - - describe "for bundle update" do - it "without any options" do - bundle! :update, :all => true - expect(out).not_to include("Gems in the groups") - expect(out).to include(bundle_updated_message) - end - - it "with --without one group" do - bundle! :install, forgotten_command_line_options(:without => "emo") - bundle! :update, :all => true - expect(out).to include("Gems in the group emo were not installed") - expect(out).to include(bundle_updated_message) - end - - it "with --without two groups" do - bundle! :install, forgotten_command_line_options(:without => "emo test") - bundle! :update, :all => true - expect(out).to include("Gems in the groups emo and test were not installed") - expect(out).to include(bundle_updated_message) - end - - it "with --without more groups" do - bundle! :install, forgotten_command_line_options(:without => "emo obama test") - bundle! :update, :all => true - expect(out).to include("Gems in the groups emo, obama and test were not installed") - expect(out).to include(bundle_updated_message) - end - end -end -- cgit v1.2.1 From d0d3f2786149cbaca6506b95e4be91be98161c15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Sun, 28 Apr 2019 15:09:03 +0200 Subject: Fix message about skipped groups for `bundle update` --- lib/bundler/cli/common.rb | 9 +++++---- lib/bundler/cli/install.rb | 2 +- lib/bundler/cli/update.rb | 2 +- spec/commands/post_bundle_message_spec.rb | 6 +++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/bundler/cli/common.rb b/lib/bundler/cli/common.rb index 5ec541f722..cec7bcadb4 100644 --- a/lib/bundler/cli/common.rb +++ b/lib/bundler/cli/common.rb @@ -14,17 +14,18 @@ module Bundler Bundler.ui.info msg end - def self.output_without_groups_message + def self.output_without_groups_message(command) return if Bundler.settings[:without].empty? - Bundler.ui.confirm without_groups_message + Bundler.ui.confirm without_groups_message(command) end - def self.without_groups_message + def self.without_groups_message(command) + command_in_past_tense = command == :install ? "installed" : "updated" groups = Bundler.settings[:without] group_list = [groups[0...-1].join(", "), groups[-1..-1]]. reject {|s| s.to_s.empty? }.join(" and ") group_str = groups.size == 1 ? "group" : "groups" - "Gems in the #{group_str} #{group_list} were not installed." + "Gems in the #{group_str} #{group_list} were not #{command_in_past_tense}." end def self.select_spec(name, regex_match = nil) diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb index cf0c71d766..d823fb632f 100644 --- a/lib/bundler/cli/install.rb +++ b/lib/bundler/cli/install.rb @@ -66,7 +66,7 @@ module Bundler Bundler.load.cache if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.frozen_bundle? Bundler.ui.confirm "Bundle complete! #{dependencies_count_for(definition)}, #{gems_installed_for(definition)}." - Bundler::CLI::Common.output_without_groups_message + Bundler::CLI::Common.output_without_groups_message(:install) if Bundler.use_system_gems? Bundler.ui.confirm "Use `bundle info [gemname]` to see where a bundled gem is installed." diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb index 45d0374eef..60ea1c2a80 100644 --- a/lib/bundler/cli/update.rb +++ b/lib/bundler/cli/update.rb @@ -95,7 +95,7 @@ module Bundler end Bundler.ui.confirm "Bundle updated!" - Bundler::CLI::Common.output_without_groups_message + Bundler::CLI::Common.output_without_groups_message(:update) Bundler::CLI::Common.output_post_install_messages installer.post_install_messages end end diff --git a/spec/commands/post_bundle_message_spec.rb b/spec/commands/post_bundle_message_spec.rb index 1efd0b8146..4d3aa7b450 100644 --- a/spec/commands/post_bundle_message_spec.rb +++ b/spec/commands/post_bundle_message_spec.rb @@ -185,21 +185,21 @@ The source does not contain any versions of 'not-a-gem' it "with --without one group" do bundle! :install, forgotten_command_line_options(:without => "emo") bundle! :update, :all => true - expect(out).to include("Gems in the group emo were not installed") + expect(out).to include("Gems in the group emo were not updated") expect(out).to include(bundle_updated_message) end it "with --without two groups" do bundle! :install, forgotten_command_line_options(:without => "emo test") bundle! :update, :all => true - expect(out).to include("Gems in the groups emo and test were not installed") + expect(out).to include("Gems in the groups emo and test were not updated") expect(out).to include(bundle_updated_message) end it "with --without more groups" do bundle! :install, forgotten_command_line_options(:without => "emo obama test") bundle! :update, :all => true - expect(out).to include("Gems in the groups emo, obama and test were not installed") + expect(out).to include("Gems in the groups emo, obama and test were not updated") expect(out).to include(bundle_updated_message) end end -- cgit v1.2.1