From 220c54b7faf056f29b2403bd27b4f8caa53f9aa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 6 Aug 2019 17:23:06 +0200 Subject: Stop printing deprecation messages during specs Previously under some circunstances (met during some specs), bundler would print deprecations to a separate UI different from "bundler's UI". This UI would not be captured by the specs, and thus would be printed to screen during the specs. This commit fixes that by making sure all deprecation messages always go through bundler's UI. --- lib/bundler/shared_helpers.rb | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index 00ff541598..62a292fcee 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -134,8 +134,9 @@ module Bundler return unless bundler_major_version >= major_version && prints_major_deprecations? @major_deprecation_ui ||= Bundler::UI::Shell.new("no-color" => true) - ui = Bundler.ui.is_a?(@major_deprecation_ui.class) ? Bundler.ui : @major_deprecation_ui - ui.warn("[DEPRECATED] #{message}") + with_major_deprecation_ui do |ui| + ui.warn("[DEPRECATED] #{message}") + end end def print_major_deprecations! @@ -212,6 +213,21 @@ module Bundler private + def with_major_deprecation_ui(&block) + ui = Bundler.ui + + if ui.is_a?(@major_deprecation_ui.class) + yield ui + else + begin + Bundler.ui = @major_deprecation_ui + yield Bundler.ui + ensure + Bundler.ui = ui + end + end + end + def validate_bundle_path path_separator = Bundler.rubygems.path_separator return unless Bundler.bundle_path.to_s.split(path_separator).size > 1 -- cgit v1.2.1