diff options
-rw-r--r-- | lib/bundler/postit_trampoline.rb | 2 | ||||
-rw-r--r-- | spec/commands/install_spec.rb | 27 | ||||
-rw-r--r-- | spec/other/trampoline_spec.rb | 31 |
3 files changed, 32 insertions, 28 deletions
diff --git a/lib/bundler/postit_trampoline.rb b/lib/bundler/postit_trampoline.rb index 643822f6a9..c464af3804 100644 --- a/lib/bundler/postit_trampoline.rb +++ b/lib/bundler/postit_trampoline.rb @@ -51,7 +51,7 @@ end if Gem::Version.new(running_version) >= Gem::Version.new("1.13.0.pre.1") ENV["BUNDLE_POSTIT_TRAMPOLINING_VERSION"] = installed_version.to_s -else +elsif ARGV.any? {|a| %w(install i).include? a } puts <<-WARN.strip You're running Bundler #{installed_version} but this project uses #{running_version}. To update, run `bundle update --bundler`.\n WARN diff --git a/spec/commands/install_spec.rb b/spec/commands/install_spec.rb index cf98d42153..89bc5eee13 100644 --- a/spec/commands/install_spec.rb +++ b/spec/commands/install_spec.rb @@ -3,18 +3,6 @@ require "spec_helper" describe "bundle install with gem sources" do describe "the simple case" do - it "warns user (once) if Bundler is outdated" do - gemfile <<-G - source "file://#{gem_repo1}" - G - - bundle :install, :env => { "BUNDLE_POSTIT_TRAMPOLINING_VERSION" => "999" } - expect(out).to include("You're running Bundler 999 but this project uses #{Bundler::VERSION}.") - - bundle :install, :env => { "BUNDLE_POSTIT_TRAMPOLINING_VERSION" => "999" } - expect(out).not_to include("You're running Bundler 999 but this project uses #{Bundler::VERSION}.") - end - it "prints output and returns if no dependencies are specified" do gemfile <<-G source "file://#{gem_repo1}" @@ -497,4 +485,19 @@ describe "bundle install with gem sources" do "setting them for authentication.") end end + + describe "warns user if Bundler is outdated" do + it "warns only once and is > 1.13.0.pre.1" do + gemfile <<-G + source "file://#{gem_repo1}" + G + ENV["BUNDLER_VERSION"] = "1.13.0.pre.1" + + bundle :install, :env => { "BUNDLE_POSTIT_TRAMPOLINING_VERSION" => "999" } + expect(out).to include("You're running Bundler 999 but this project uses #{ENV["BUNDLER_VERSION"]}.") + + bundle :install, :env => { "BUNDLE_POSTIT_TRAMPOLINING_VERSION" => "999" } + expect(out).not_to include("You're running Bundler 999 but this project uses #{ENV["BUNDLER_VERSION"]}.") + end + end end diff --git a/spec/other/trampoline_spec.rb b/spec/other/trampoline_spec.rb index 54be4314dd..8f73050eae 100644 --- a/spec/other/trampoline_spec.rb +++ b/spec/other/trampoline_spec.rb @@ -7,21 +7,6 @@ describe "bundler version trampolining" do FileUtils.rm_rf(system_gem_path) FileUtils.cp_r(base_system_gems, system_gem_path) end - context "warnings" do - it "warns user if Bundler is outdated and is < 1.13.0.pre.1" do - ENV["BUNDLER_VERSION"] = "1.12.0" - bundle! "--version" - expect(out).to include(<<-WARN.strip) -You're running Bundler #{Bundler::VERSION} but this project uses #{ENV["BUNDLER_VERSION"]}. To update, run `bundle update --bundler`.\n - WARN - - ENV["BUNDLER_VERSION"] = "1.13.0.pre.1" - bundle! "--version" - expect(out).not_to include(<<-WARN.strip) -You're running Bundler #{Bundler::VERSION} but this project uses #{ENV["BUNDLER_VERSION"]}. To update, run `bundle update --bundler`.\n - WARN - end - end context "version guessing" do shared_examples_for "guesses" do |version| @@ -149,4 +134,20 @@ The error was: expect(out).to eq("1.12.0") end end + + context "warnings" do + before do + simulate_bundler_version("1.12.0") do + install_gemfile "" + end + end + + it "warns user if Bundler is outdated and is < 1.13.0.pre.1" do + ENV["BUNDLER_VERSION"] = "1.12.0" + bundle! "install" + expect(out).to include(<<-WARN.strip) +You're running Bundler #{Bundler::VERSION} but this project uses #{ENV["BUNDLER_VERSION"]}. To update, run `bundle update --bundler`.\n + WARN + end + end end |