diff options
Diffstat (limited to 'spec/bundler/commands')
-rw-r--r-- | spec/bundler/commands/add_spec.rb | 26 | ||||
-rw-r--r-- | spec/bundler/commands/binstubs_spec.rb | 18 | ||||
-rw-r--r-- | spec/bundler/commands/check_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/commands/config_spec.rb | 38 | ||||
-rw-r--r-- | spec/bundler/commands/exec_spec.rb | 35 | ||||
-rw-r--r-- | spec/bundler/commands/init_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/commands/install_spec.rb | 4 | ||||
-rw-r--r-- | spec/bundler/commands/licenses_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/commands/lock_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/commands/newgem_spec.rb | 40 | ||||
-rw-r--r-- | spec/bundler/commands/outdated_spec.rb | 20 | ||||
-rw-r--r-- | spec/bundler/commands/package_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/commands/post_bundle_message_spec.rb | 206 | ||||
-rw-r--r-- | spec/bundler/commands/show_spec.rb | 37 | ||||
-rw-r--r-- | spec/bundler/commands/update_spec.rb | 74 |
15 files changed, 394 insertions, 114 deletions
diff --git a/spec/bundler/commands/add_spec.rb b/spec/bundler/commands/add_spec.rb index dac1d0f6b9..f5b3f49bb1 100644 --- a/spec/bundler/commands/add_spec.rb +++ b/spec/bundler/commands/add_spec.rb @@ -11,6 +11,8 @@ RSpec.describe "bundle add" do build_gem "dog", "1.1.3.pre" end + build_git "foo", "2.0" + install_gemfile <<-G source "file://#{gem_repo2}" gem "weakling", "~> 0.0.1" @@ -21,7 +23,7 @@ RSpec.describe "bundle add" do it "shows error" do bundle "add" - expect(last_command.bundler_err).to include("Please specify gems to add") + expect(err).to include("Please specify gems to add") end end @@ -89,6 +91,28 @@ RSpec.describe "bundle add" do end end + describe "with --git" do + it "adds dependency with specified github source" do + bundle "add foo --git=#{lib_path("foo-2.0")}" + + expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}"/) + expect(the_bundle).to include_gems "foo 2.0" + end + end + + describe "with --git and --branch" do + before do + update_git "foo", "2.0", :branch => "test" + end + + it "adds dependency with specified github source and branch" do + bundle "add foo --git=#{lib_path("foo-2.0")} --branch=test" + + expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}", :branch => "test"/) + expect(the_bundle).to include_gems "foo 2.0" + end + end + describe "with --skip-install" do it "adds gem to Gemfile but is not installed" do bundle "add foo --skip-install --version=2.0" diff --git a/spec/bundler/commands/binstubs_spec.rb b/spec/bundler/commands/binstubs_spec.rb index 92fa6812b0..4f310784c7 100644 --- a/spec/bundler/commands/binstubs_spec.rb +++ b/spec/bundler/commands/binstubs_spec.rb @@ -70,7 +70,7 @@ RSpec.describe "bundle binstubs <gem>" do bundle "binstubs rack", :all => true expect(last_command).to be_failure - expect(last_command.bundler_err).to include("Cannot specify --all with specific gems") + expect(err).to include("Cannot specify --all with specific gems") end context "when generating bundle binstub outside bundler" do @@ -88,7 +88,7 @@ RSpec.describe "bundle binstubs <gem>" do sys_exec "bin/rackup" - expect(last_command.stderr).to include("was not generated by Bundler") + expect(err).to include("was not generated by Bundler") end end @@ -135,7 +135,7 @@ RSpec.describe "bundle binstubs <gem>" do it "runs the correct version of bundler" do sys_exec "#{bundled_app("bin/bundle")} install", "BUNDLER_VERSION" => "999.999.999" expect(exitstatus).to eq(42) if exitstatus - expect(last_command.stderr).to include("Activating bundler (999.999.999) failed:"). + expect(err).to include("Activating bundler (999.999.999) failed:"). and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`") end end @@ -145,7 +145,7 @@ RSpec.describe "bundle binstubs <gem>" do lockfile lockfile.gsub(system_bundler_version, "999.999.999") sys_exec "#{bundled_app("bin/bundle")} install" expect(exitstatus).to eq(42) if exitstatus - expect(last_command.stderr).to include("Activating bundler (999.999.999) failed:"). + expect(err).to include("Activating bundler (999.999.999) failed:"). and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`") end @@ -154,7 +154,7 @@ RSpec.describe "bundle binstubs <gem>" do lockfile lockfile.gsub(system_bundler_version, "44.0") sys_exec "#{bundled_app("bin/bundle")} install" expect(exitstatus).to eq(42) if exitstatus - expect(last_command.stderr).to include("Activating bundler (44.0) failed:"). + expect(err).to include("Activating bundler (44.0) failed:"). and include("To install the version of bundler this project requires, run `gem install bundler -v '44.0'`") end @@ -163,7 +163,7 @@ RSpec.describe "bundle binstubs <gem>" do lockfile lockfile.gsub(system_bundler_version, "2.12.0.a") sys_exec "#{bundled_app("bin/bundle")} install" expect(exitstatus).to eq(42) if exitstatus - expect(last_command.stderr).to include("Activating bundler (2.12.0.a) failed:"). + expect(err).to include("Activating bundler (2.12.0.a) failed:"). and include("To install the version of bundler this project requires, run `gem install bundler -v '2.12.0.a'`") end end @@ -173,13 +173,13 @@ RSpec.describe "bundle binstubs <gem>" do it "calls through to the latest bundler version" do sys_exec! "#{bundled_app("bin/bundle")} update --bundler" - expect(last_command.stdout).to eq %(system bundler #{system_bundler_version}\n["update", "--bundler"]) + expect(out).to eq %(system bundler #{system_bundler_version}\n["update", "--bundler"]) end it "calls through to the explicit bundler version" do sys_exec "#{bundled_app("bin/bundle")} update --bundler=999.999.999" expect(exitstatus).to eq(42) if exitstatus - expect(last_command.stderr).to include("Activating bundler (999.999.999) failed:"). + expect(err).to include("Activating bundler (999.999.999) failed:"). and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`") end end @@ -205,7 +205,7 @@ RSpec.describe "bundle binstubs <gem>" do it "attempts to load that version" do sys_exec bundled_app("bin/rackup").to_s expect(exitstatus).to eq(42) if exitstatus - expect(last_command.stderr).to include("Activating bundler (999.999.999) failed:"). + expect(err).to include("Activating bundler (999.999.999) failed:"). and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`") end end diff --git a/spec/bundler/commands/check_spec.rb b/spec/bundler/commands/check_spec.rb index 7114610644..cf88736612 100644 --- a/spec/bundler/commands/check_spec.rb +++ b/spec/bundler/commands/check_spec.rb @@ -338,7 +338,7 @@ RSpec.describe "bundle check" do it "does not change the lock but warns" do lockfile lock_with(Bundler::VERSION.succ) bundle! :check - expect(last_command.bundler_err).to include("the running version of Bundler (#{Bundler::VERSION}) is older than the version that created the lockfile (#{Bundler::VERSION.succ})") + expect(err).to include("the running version of Bundler (#{Bundler::VERSION}) is older than the version that created the lockfile (#{Bundler::VERSION.succ})") lockfile_should_be lock_with(Bundler::VERSION.succ) end end diff --git a/spec/bundler/commands/config_spec.rb b/spec/bundler/commands/config_spec.rb index 976916a9fe..40fab95803 100644 --- a/spec/bundler/commands/config_spec.rb +++ b/spec/bundler/commands/config_spec.rb @@ -391,86 +391,86 @@ E describe "subcommands" do it "list", :ruby_repo do bundle! "config list" - expect(last_command.stdout).to eq "Settings are listed in order of priority. The top value will be used.\nspec_run\nSet via BUNDLE_SPEC_RUN: \"true\"" + expect(out).to eq "Settings are listed in order of priority. The top value will be used.\nspec_run\nSet via BUNDLE_SPEC_RUN: \"true\"" bundle! "config list", :parseable => true - expect(last_command.stdout).to eq "spec_run=true" + expect(out).to eq "spec_run=true" end it "get" do ENV["BUNDLE_BAR"] = "bar_val" bundle! "config get foo" - expect(last_command.stdout).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" + expect(out).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" ENV["BUNDLE_FOO"] = "foo_val" bundle! "config get foo --parseable" - expect(last_command.stdout).to eq "foo=foo_val" + expect(out).to eq "foo=foo_val" bundle! "config get foo" - expect(last_command.stdout).to eq "Settings for `foo` in order of priority. The top value will be used\nSet via BUNDLE_FOO: \"foo_val\"" + expect(out).to eq "Settings for `foo` in order of priority. The top value will be used\nSet via BUNDLE_FOO: \"foo_val\"" end it "set" do bundle! "config set foo 1" - expect(last_command.stdout).to eq "" + expect(out).to eq "" bundle! "config set --local foo 2" - expect(last_command.stdout).to eq "" + expect(out).to eq "" bundle! "config set --global foo 3" - expect(last_command.stdout).to eq "Your application has set foo to \"2\". This will override the global value you are currently setting" + expect(out).to eq "Your application has set foo to \"2\". This will override the global value you are currently setting" bundle! "config set --parseable --local foo 4" - expect(last_command.stdout).to eq "foo=4" + expect(out).to eq "foo=4" bundle! "config set --local foo 4.1" - expect(last_command.stdout).to eq "You are replacing the current local value of foo, which is currently \"4\"" + expect(out).to eq "You are replacing the current local value of foo, which is currently \"4\"" bundle "config set --global --local foo 5" expect(last_command).to be_failure - expect(last_command.bundler_err).to eq "The options global and local were specified. Please only use one of the switches at a time." + expect(err).to eq "The options global and local were specified. Please only use one of the switches at a time." end it "unset" do bundle! "config unset foo" - expect(last_command.stdout).to eq "" + expect(out).to eq "" bundle! "config set foo 1" bundle! "config unset foo --parseable" - expect(last_command.stdout).to eq "" + expect(out).to eq "" bundle! "config set --local foo 1" bundle! "config set --global foo 2" bundle! "config unset foo" - expect(last_command.stdout).to eq "" + expect(out).to eq "" expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" bundle! "config set --local foo 1" bundle! "config set --global foo 2" bundle! "config unset foo --local" - expect(last_command.stdout).to eq "" + expect(out).to eq "" expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nSet for the current user (#{home(".bundle/config")}): \"2\"" bundle! "config unset foo --global" - expect(last_command.stdout).to eq "" + expect(out).to eq "" expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" bundle! "config set --local foo 1" bundle! "config set --global foo 2" bundle! "config unset foo --global" - expect(last_command.stdout).to eq "" + expect(out).to eq "" expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nSet for your local app (#{bundled_app(".bundle/config")}): \"1\"" bundle! "config unset foo --local" - expect(last_command.stdout).to eq "" + expect(out).to eq "" expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" bundle "config unset foo --local --global" expect(last_command).to be_failure - expect(last_command.bundler_err).to eq "The options global and local were specified. Please only use one of the switches at a time." + expect(err).to eq "The options global and local were specified. Please only use one of the switches at a time." end end end diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb index 66096a91a1..8f49c576b5 100644 --- a/spec/bundler/commands/exec_spec.rb +++ b/spec/bundler/commands/exec_spec.rb @@ -55,6 +55,17 @@ RSpec.describe "bundle exec" do expect(out).to eq("hi") end + it "respects custom process title when loading through ruby" do + script_that_changes_its_own_title_and_checks_if_picked_up_by_ps_unix_utility = <<~RUBY + Process.setproctitle("1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16") + puts `ps -eo args | grep [1]-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16` + RUBY + create_file "Gemfile" + create_file "a.rb", script_that_changes_its_own_title_and_checks_if_picked_up_by_ps_unix_utility + bundle "exec ruby a.rb" + expect(out).to eq("1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16") + end + it "accepts --verbose" do install_gemfile 'gem "rack"' bundle "exec --verbose echo foobar" @@ -88,14 +99,14 @@ RSpec.describe "bundle exec" do sys_exec "#{Gem.ruby} #{command.path}" expect(out).to eq("") - expect(last_command.stderr).to be_empty + expect(err).to be_empty end it "accepts --keep-file-descriptors" do install_gemfile "" bundle "exec --keep-file-descriptors echo foobar" - expect(last_command.stderr).to be_empty + expect(err).to be_empty end it "can run a command named --verbose" do @@ -156,7 +167,7 @@ RSpec.describe "bundle exec" do bundle! "exec irb --version" expect(out).to include(default_irb_version) - expect(last_command.stderr).to be_empty + expect(err).to be_empty end end @@ -182,7 +193,7 @@ RSpec.describe "bundle exec" do bundle! "exec irb --version" expect(out).to include(specified_irb_version) - expect(last_command.stderr).to be_empty + expect(err).to be_empty end end @@ -212,7 +223,7 @@ RSpec.describe "bundle exec" do it "uses resolved version" do expect(out).to include(indirect_irb_version) - expect(last_command.stderr).to be_empty + expect(err).to be_empty end end end @@ -268,7 +279,7 @@ RSpec.describe "bundle exec" do G rubyopt = ENV["RUBYOPT"] - rubyopt = "-rbundler/setup #{rubyopt}" + rubyopt = "-r#{File.expand_path("../../lib/bundler/setup", __dir__)} #{rubyopt}" bundle "exec 'echo $RUBYOPT'" expect(out).to have_rubyopts(rubyopt) @@ -334,7 +345,7 @@ RSpec.describe "bundle exec" do [true, false].each do |l| bundle! "config set disable_exec_load #{l}" bundle "exec rackup" - expect(last_command.stderr).to include "can't find executable rackup for gem rack. rack is not currently included in the bundle, perhaps you meant to add it to your Gemfile?" + expect(err).to include "can't find executable rackup for gem rack. rack is not currently included in the bundle, perhaps you meant to add it to your Gemfile?" end end @@ -552,8 +563,8 @@ RSpec.describe "bundle exec" do bundle "exec irb" - expect(last_command.stderr).to match("The gemspec at #{lib_path("foo-1.0").join("foo.gemspec")} is not valid") - expect(last_command.stderr).to match('"TODO" is not a summary') + expect(err).to match("The gemspec at #{lib_path("foo-1.0").join("foo.gemspec")} is not valid") + expect(err).to match('"TODO" is not a summary') end end @@ -614,8 +625,8 @@ RSpec.describe "bundle exec" do it "like a normally executed executable" do subject expect(exitstatus).to eq(exit_code) if exitstatus - expect(last_command.stderr).to eq(expected_err) - expect(last_command.stdout).to eq(expected) + expect(err).to eq(expected_err) + expect(out).to eq(expected) end end @@ -886,7 +897,7 @@ __FILE__: #{path.to_s.inspect} # sanity check that we get the newer, custom version without bundler sys_exec("#{Gem.ruby} #{file}") - expect(last_command.stderr).to include("custom openssl should not be loaded") + expect(err).to include("custom openssl should not be loaded") end end end diff --git a/spec/bundler/commands/init_spec.rb b/spec/bundler/commands/init_spec.rb index 64849beeb9..7960ce85bd 100644 --- a/spec/bundler/commands/init_spec.rb +++ b/spec/bundler/commands/init_spec.rb @@ -94,7 +94,7 @@ RSpec.describe "bundle init" do end bundle :init, :gemspec => spec_file - expect(last_command.bundler_err).to include("There was an error while loading `test.gemspec`") + expect(err).to include("There was an error while loading `test.gemspec`") end end end diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb index 21157dd309..1a027a77c9 100644 --- a/spec/bundler/commands/install_spec.rb +++ b/spec/bundler/commands/install_spec.rb @@ -16,7 +16,7 @@ RSpec.describe "bundle install with gem sources" do raise StandardError, "FAIL" G - expect(last_command.bundler_err).to include('StandardError, "FAIL"') + expect(err).to include('StandardError, "FAIL"') expect(bundled_app("Gemfile.lock")).not_to exist end @@ -404,7 +404,7 @@ RSpec.describe "bundle install with gem sources" do G expect(last_command.stdboth).not_to match(/Error Report/i) - expect(last_command.bundler_err).to include("An error occurred while installing ajp-rails (0.0.0), and Bundler cannot continue."). + expect(err).to include("An error occurred while installing ajp-rails (0.0.0), and Bundler cannot continue."). and include(normalize_uri_file("Make sure that `gem install ajp-rails -v '0.0.0' --source 'file://localhost#{gem_repo2}/'` succeeds before bundling.")) end diff --git a/spec/bundler/commands/licenses_spec.rb b/spec/bundler/commands/licenses_spec.rb index 21fd8eaf2f..423921e282 100644 --- a/spec/bundler/commands/licenses_spec.rb +++ b/spec/bundler/commands/licenses_spec.rb @@ -12,7 +12,7 @@ RSpec.describe "bundle licenses" do it "prints license information for all gems in the bundle" do bundle "licenses" - expect(err).to include("bundler: Unknown") + expect(out).to include("bundler: MIT") expect(out).to include("with_license: MIT") end diff --git a/spec/bundler/commands/lock_spec.rb b/spec/bundler/commands/lock_spec.rb index f876d719cc..7aaf5c178e 100644 --- a/spec/bundler/commands/lock_spec.rb +++ b/spec/bundler/commands/lock_spec.rb @@ -242,7 +242,7 @@ RSpec.describe "bundle lock" do it "errors when removing all platforms" do bundle "lock --remove-platform #{local_platforms.join(" ")}" - expect(last_command.bundler_err).to include("Removing all platforms from the bundle is not allowed") + expect(err).to include("Removing all platforms from the bundle is not allowed") end # from https://github.com/bundler/bundler/issues/4896 diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb index 528ebf7c2b..203b474877 100644 --- a/spec/bundler/commands/newgem_spec.rb +++ b/spec/bundler/commands/newgem_spec.rb @@ -1,11 +1,6 @@ # frozen_string_literal: true RSpec.describe "bundle gem" do - def reset! - super - global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false" - end - def execute_bundle_gem(gem_name, flag = "") bundle! "gem #{gem_name} #{flag}" # reset gemspec cache for each test because of commit 3d4163a @@ -22,6 +17,7 @@ RSpec.describe "bundle gem" do end before do + global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false" git_config_content = <<-EOF [user] name = "Bundler User" @@ -136,7 +132,6 @@ RSpec.describe "bundle gem" do context "git config github.user is absent" do before do sys_exec("git config --unset github.user") - reset! in_app_root bundle "gem #{gem_name}" end @@ -209,7 +204,6 @@ RSpec.describe "bundle gem" do context "gem naming with relative paths" do before do - reset! in_app_root end @@ -281,7 +275,6 @@ RSpec.describe "bundle gem" do before do `git config --unset user.name` `git config --unset user.email` - reset! in_app_root bundle "gem #{gem_name}" end @@ -322,7 +315,6 @@ RSpec.describe "bundle gem" do context "--exe parameter set" do before do - reset! in_app_root bundle "gem #{gem_name} --exe" end @@ -338,7 +330,6 @@ RSpec.describe "bundle gem" do context "--bin parameter set" do before do - reset! in_app_root bundle "gem #{gem_name} --bin" end @@ -354,7 +345,6 @@ RSpec.describe "bundle gem" do context "no --test parameter" do before do - reset! in_app_root bundle "gem #{gem_name}" end @@ -370,7 +360,6 @@ RSpec.describe "bundle gem" do context "--test parameter set to rspec" do before do - reset! in_app_root bundle "gem #{gem_name} --test=rspec" end @@ -397,7 +386,6 @@ RSpec.describe "bundle gem" do context "gem.test setting set to rspec" do before do - reset! in_app_root bundle "config set gem.test rspec" bundle "gem #{gem_name}" @@ -412,7 +400,6 @@ RSpec.describe "bundle gem" do context "gem.test setting set to rspec and --test is set to minitest" do before do - reset! in_app_root bundle "config set gem.test rspec" bundle "gem #{gem_name} --test=minitest" @@ -426,7 +413,6 @@ RSpec.describe "bundle gem" do context "--test parameter set to minitest" do before do - reset! in_app_root bundle "gem #{gem_name} --test=minitest" end @@ -456,7 +442,6 @@ RSpec.describe "bundle gem" do context "gem.test setting set to minitest" do before do - reset! in_app_root bundle "config set gem.test minitest" bundle "gem #{gem_name}" @@ -482,7 +467,6 @@ RSpec.describe "bundle gem" do context "--test with no arguments" do before do - reset! in_app_root bundle "gem #{gem_name} --test" end @@ -499,7 +483,6 @@ RSpec.describe "bundle gem" do context "--edit option" do it "opens the generated gemspec in the user's text editor" do - reset! in_app_root output = bundle "gem #{gem_name} --edit=echo" gemspec_path = File.join(Dir.pwd, gem_name, "#{gem_name}.gemspec") @@ -515,7 +498,6 @@ RSpec.describe "bundle gem" do before do global_config "BUNDLE_GEM__MIT" => "true", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false" end - after { reset! } it_behaves_like "--mit flag" it_behaves_like "--no-mit flag" end @@ -529,7 +511,6 @@ RSpec.describe "bundle gem" do before do global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "true" end - after { reset! } it_behaves_like "--coc flag" it_behaves_like "--no-coc flag" end @@ -572,7 +553,6 @@ RSpec.describe "bundle gem" do before do `git config --unset user.name` `git config --unset user.email` - reset! in_app_root bundle "gem #{gem_name}" end @@ -604,7 +584,6 @@ RSpec.describe "bundle gem" do context "--bin parameter set" do before do - reset! in_app_root bundle "gem #{gem_name} --bin" end @@ -620,7 +599,6 @@ RSpec.describe "bundle gem" do context "no --test parameter" do before do - reset! in_app_root bundle "gem #{gem_name}" end @@ -636,7 +614,6 @@ RSpec.describe "bundle gem" do context "--test parameter set to rspec" do before do - reset! in_app_root bundle "gem #{gem_name} --test=rspec" end @@ -671,7 +648,6 @@ RSpec.describe "bundle gem" do context "--test parameter set to minitest" do before do - reset! in_app_root bundle "gem #{gem_name} --test=minitest" end @@ -713,7 +689,6 @@ RSpec.describe "bundle gem" do context "--test with no arguments" do before do - reset! in_app_root bundle "gem #{gem_name} --test" end @@ -726,7 +701,6 @@ RSpec.describe "bundle gem" do context "--ext parameter set" do before do - reset! in_app_root bundle "gem test_gem --ext" end @@ -770,22 +744,22 @@ RSpec.describe "bundle gem" do it "fails gracefully with a ." do bundle "gem foo.gemspec" - expect(last_command.bundler_err).to end_with("Invalid gem name foo.gemspec -- `Foo.gemspec` is an invalid constant name") + expect(err).to end_with("Invalid gem name foo.gemspec -- `Foo.gemspec` is an invalid constant name") end it "fails gracefully with a ^" do bundle "gem ^" - expect(last_command.bundler_err).to end_with("Invalid gem name ^ -- `^` is an invalid constant name") + expect(err).to end_with("Invalid gem name ^ -- `^` is an invalid constant name") end it "fails gracefully with a space" do bundle "gem 'foo bar'" - expect(last_command.bundler_err).to end_with("Invalid gem name foo bar -- `Foo bar` is an invalid constant name") + expect(err).to end_with("Invalid gem name foo bar -- `Foo bar` is an invalid constant name") end it "fails gracefully when multiple names are passed" do bundle "gem foo bar baz" - expect(last_command.bundler_err).to eq(<<-E.strip) + expect(err).to eq(<<-E.strip) ERROR: "bundle gem" was called with arguments ["foo", "bar", "baz"] Usage: "bundle gem NAME [OPTIONS]" E @@ -876,7 +850,7 @@ Usage: "bundle gem NAME [OPTIONS]" FileUtils.touch("conflict-foobar") end bundle "gem conflict-foobar" - expect(last_command.bundler_err).to include("Errno::ENOTDIR") + expect(err).to include("Errno::ENOTDIR") expect(exitstatus).to eql(32) if exitstatus end end @@ -887,7 +861,7 @@ Usage: "bundle gem NAME [OPTIONS]" FileUtils.mkdir_p("conflict-foobar/Gemfile") end bundle! "gem conflict-foobar" - expect(last_command.stdout).to include("file_clash conflict-foobar/Gemfile"). + expect(out).to include("file_clash conflict-foobar/Gemfile"). and include "Initializing git repo in #{bundled_app("conflict-foobar")}" end end diff --git a/spec/bundler/commands/outdated_spec.rb b/spec/bundler/commands/outdated_spec.rb index 843bebf6e0..f0c2927218 100644 --- a/spec/bundler/commands/outdated_spec.rb +++ b/spec/bundler/commands/outdated_spec.rb @@ -59,15 +59,19 @@ RSpec.describe "bundle outdated" do install_gemfile <<-G source "file://#{gem_repo2}" + gem "terranova", '8' + group :development, :test do gem 'activesupport', '2.3.5' end G update_repo2 { build_gem "activesupport", "3.0" } + update_repo2 { build_gem "terranova", "9" } bundle "outdated --verbose" expect(out).to include("activesupport (newest 3.0, installed 2.3.5, requested = 2.3.5) in groups \"development, test\"") + expect(out).to include("terranova (newest 9, installed 8, requested = 8) in group \"default\"") end end @@ -117,10 +121,10 @@ RSpec.describe "bundle outdated" do it "returns a sorted list of outdated gems from one group => 'default'" do test_group_option("default") - expect(out).to include("===== Group default =====") + expect(out).to include("===== Group \"default\" =====") expect(out).to include("terranova (") - expect(out).not_to include("===== Group development, test =====") + expect(out).not_to include("===== Groups \"development, test\" =====") expect(out).not_to include("activesupport") expect(out).not_to include("duradura") end @@ -128,10 +132,10 @@ RSpec.describe "bundle outdated" do it "returns a sorted list of outdated gems from one group => 'development'" do test_group_option("development", 2) - expect(out).not_to include("===== Group default =====") + expect(out).not_to include("===== Group \"default\" =====") expect(out).not_to include("terranova (") - expect(out).to include("===== Group development, test =====") + expect(out).to include("===== Groups \"development, test\" =====") expect(out).to include("activesupport") expect(out).to include("duradura") end @@ -139,10 +143,10 @@ RSpec.describe "bundle outdated" do it "returns a sorted list of outdated gems from one group => 'test'" do test_group_option("test", 2) - expect(out).not_to include("===== Group default =====") + expect(out).not_to include("===== Group \"default\" =====") expect(out).not_to include("terranova (") - expect(out).to include("===== Group development, test =====") + expect(out).to include("===== Groups \"development, test\" =====") expect(out).to include("activesupport") expect(out).to include("duradura") end @@ -184,9 +188,9 @@ RSpec.describe "bundle outdated" do end bundle "outdated --groups" - expect(out).to include("===== Group default =====") + expect(out).to include("===== Group \"default\" =====") expect(out).to include("terranova (newest 9, installed 8, requested = 8)") - expect(out).to include("===== Group development, test =====") + expect(out).to include("===== Groups \"development, test\" =====") expect(out).to include("activesupport (newest 3.0, installed 2.3.5, requested = 2.3.5)") expect(out).to include("duradura (newest 8.0, installed 7.0, requested = 7.0)") diff --git a/spec/bundler/commands/package_spec.rb b/spec/bundler/commands/package_spec.rb index 6cd8e3f85a..b9cc079c5c 100644 --- a/spec/bundler/commands/package_spec.rb +++ b/spec/bundler/commands/package_spec.rb @@ -278,7 +278,7 @@ RSpec.describe "bundle install with gem sources" do end bundle :install - expect(last_command.stderr).to be_empty + expect(err).to be_empty expect(the_bundle).to include_gems "rack 1.0" end diff --git a/spec/bundler/commands/post_bundle_message_spec.rb b/spec/bundler/commands/post_bundle_message_spec.rb new file mode 100644 index 0000000000..4d3aa7b450 --- /dev/null +++ b/spec/bundler/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 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 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 updated") + expect(out).to include(bundle_updated_message) + end + end +end diff --git a/spec/bundler/commands/show_spec.rb b/spec/bundler/commands/show_spec.rb index 6e1986e35f..6a7d5f267e 100644 --- a/spec/bundler/commands/show_spec.rb +++ b/spec/bundler/commands/show_spec.rb @@ -30,21 +30,11 @@ RSpec.describe "bundle show", :bundler => "< 3" do expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s) end - it "prints deprecation" do - bundle "show rails" - expect(err).to eq("[DEPRECATED] use `bundle info rails` instead of `bundle show rails`") - end - it "prints path if gem exists in bundle (with --paths option)" do bundle "show rails --paths" expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s) end - it "prints deprecation when called with a gem and the --paths option" do - bundle "show rails --paths" - expect(err).to eq("[DEPRECATED] use `bundle info rails --path` instead of `bundle show rails --paths`") - end - it "warns if path no longer exists on disk" do FileUtils.rm_rf(default_bundle_path("gems", "rails-2.3.2")) @@ -59,10 +49,6 @@ RSpec.describe "bundle show", :bundler => "< 3" do expect(out).to eq(root.to_s) end - it "prints deprecation when called with bundler" do - bundle "show bundler" - expect(err).to eq("[DEPRECATED] use `bundle info bundler` instead of `bundle show bundler`") - end it "complains if gem not in bundle" do bundle "show missing" expect(err).to match(/could not find gem 'missing'/i) @@ -79,19 +65,26 @@ RSpec.describe "bundle show", :bundler => "< 3" do expect(gem_list).to eq(gem_list.sort) end - it "prints a deprecation when called with the --paths option" do - bundle "show --paths" + it "prints summary of gems" do + bundle "show --verbose" - expect(err).to eq("[DEPRECATED] use `bundle list` instead of `bundle show --paths`") + 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 end - it "prints summary of gems" do + it "includes bundler in the summary of gems" do bundle "show --verbose" - expect(out).to include("* actionmailer (2.3.2)") - expect(out).to include("\tSummary: This is just a fake gem for testing") - expect(out).to include("\tHomepage: No website available.") - expect(out).to include("\tStatus: Up to date") + 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 end end diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb index 46c208db6c..61a5a1d1f1 100644 --- a/spec/bundler/commands/update_spec.rb +++ b/spec/bundler/commands/update_spec.rb @@ -473,6 +473,39 @@ RSpec.describe "bundle update in more complicated situations" do expect(the_bundle).to include_gems "thin 2.0", "rack 10.0", "rack-obama 1.0" end + it "will not warn when an explicitly updated git gem changes sha but not version" do + build_git "foo" + + install_gemfile! <<-G + gem "foo", :git => '#{lib_path("foo-1.0")}' + G + + update_git "foo" do |s| + s.write "lib/foo2.rb", "puts :foo2" + end + + bundle! "update foo" + + expect(last_command.stdboth).not_to include "attempted to update" + end + + it "will not warn when changing gem sources but not versions" do + build_git "rack" + + install_gemfile! <<-G + gem "rack", :git => '#{lib_path("rack-1.0")}' + G + + gemfile <<-G + source "file://#{gem_repo1}" + gem "rack" + G + + bundle! "update rack" + + expect(last_command.stdboth).not_to include "attempted to update" + end + it "will update only from pinned source" do install_gemfile <<-G source "file://#{gem_repo2}" @@ -530,6 +563,41 @@ RSpec.describe "bundle update in more complicated situations" do expect(the_bundle).to include_gem "a 1.1" end end + + context "when the dependency is for a different platform" do + before do + build_repo4 do + build_gem("a", "0.9") {|s| s.platform = "java" } + build_gem("a", "1.1") {|s| s.platform = "java" } + end + + gemfile <<-G + source "file://#{gem_repo4}" + gem "a", platform: :jruby + G + + lockfile <<-L + GEM + remote: file://#{gem_repo4} + specs: + a (0.9-java) + + PLATFORMS + java + + DEPENDENCIES + a + L + + simulate_platform linux + end + + it "is not updated because it is not actually included in the bundle" do + bundle! "update a" + expect(last_command.stdboth).to include "Bundler attempted to update a but it was not considered because it is for a different platform from the current one" + expect(the_bundle).to_not include_gem "a" + end + end end RSpec.describe "bundle update without a Gemfile.lock" do @@ -565,13 +633,13 @@ RSpec.describe "bundle update when a gem depends on a newer version of bundler" it "should explain that bundler conflicted", :bundler => "< 3" do bundle "update", :all => true expect(last_command.stdboth).not_to match(/in snapshot/i) - expect(last_command.bundler_err).to match(/current Bundler version/i). + expect(err).to match(/current Bundler version/i). and match(/perhaps you need to update bundler/i) end it "should warn that the newer version of Bundler would conflict", :bundler => "3" do bundle! "update", :all => true - expect(last_command.bundler_err).to include("rails (3.0.1) has dependency bundler"). + expect(err).to include("rails (3.0.1) has dependency bundler"). and include("so the dependency is being ignored") expect(the_bundle).to include_gem "rails 3.0.1" end @@ -947,7 +1015,7 @@ RSpec.describe "bundle update conservative" do it "raises if too many flags are provided" do bundle "update --patch --minor", :all => true - expect(last_command.bundler_err).to eq "Provide only one of the following options: minor, patch" + expect(err).to eq "Provide only one of the following options: minor, patch" end end end |