diff options
-rw-r--r-- | lib/bundler/ui/shell.rb | 5 | ||||
-rw-r--r-- | spec/bundler/ui/shell_spec.rb | 15 |
2 files changed, 17 insertions, 3 deletions
diff --git a/lib/bundler/ui/shell.rb b/lib/bundler/ui/shell.rb index a1a2cbad18..e0d0d68aa9 100644 --- a/lib/bundler/ui/shell.rb +++ b/lib/bundler/ui/shell.rb @@ -30,9 +30,12 @@ module Bundler end def warn(msg, newline = nil) + return unless level("warn") return if @warning_history.include? msg @warning_history << msg - tell_me(msg, :yellow, newline) if level("warn") + + return tell_err(msg, :yellow, newline) if Bundler.feature_flag.error_on_stderr? + tell_me(msg, :yellow, newline) end def error(msg, newline = nil) diff --git a/spec/bundler/ui/shell_spec.rb b/spec/bundler/ui/shell_spec.rb index 6585ab1da8..9a47a3572f 100644 --- a/spec/bundler/ui/shell_spec.rb +++ b/spec/bundler/ui/shell_spec.rb @@ -21,9 +21,20 @@ RSpec.describe Bundler::UI::Shell do describe "#warn" do before { subject.level = "warn" } - it "prints to stdout" do + it "prints to stdout", :bundler => "< 2" do expect { subject.warn("warning") }.to output("warning\n").to_stdout end + + it "prints to stderr", :bundler => "2" do + expect { subject.warn("warning") }.to output("warning\n").to_stderr + end + + context "when stderr flag is enabled" do + before { Bundler.settings.temporary(:error_on_stderr => true) } + it "prints to stderr" do + expect { subject.warn("warning!") }.to output("warning!\n").to_stderr + end + end end describe "#debug" do @@ -35,7 +46,7 @@ RSpec.describe Bundler::UI::Shell do describe "#error" do before { subject.level = "error" } - it "prints to stdout", :bundler => "<= 2" do + it "prints to stdout", :bundler => "< 2" do expect { subject.error("error!!!") }.to output("error!!!\n").to_stdout end |