From 1d20e4f4312d78db78bde4858e26f7d389d8925e Mon Sep 17 00:00:00 2001 From: Francois Date: Thu, 5 Oct 2023 16:50:46 +0200 Subject: [PATCH] Disable VERBOSE warnings in test stubs (#466) To prevent warning during tests while we deliberately override certain methods. Warnings include: rubycritic/test/fakefs_helper.rb:8: warning: method redefined; discarding old flock rubycritic/.bundle/ruby/3.2.0/gems/fakefs-2.4.0/lib/fakefs/file.rb:586: warning: previous definition of flock was here rubycritic/test/lib/rubycritic/commands/compare_test.rb:12: warning: method redefined; discarding old current_branch rubycritic/lib/rubycritic/source_control_systems/git.rb:82: warning: previous definition of current_branch was here See: https://github.com/whitesmith/rubycritic/issues/465 --- CHANGELOG.md | 1 + test/fakefs_helper.rb | 4 ++++ test/lib/rubycritic/commands/compare_test.rb | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e70f83f6..529eb58d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ * [CHANGE] Fix test warning related to `cucumber_opts` declaration (by [@faisal][]) * [BUGFIX] Stop using long-deprecated MiniTest module name, removed in 5.19.0 (by [@faisal][]) +* [CHANGE] Disable VERBOSE warnings in test stubs (by [@fbuys][]) # v4.8.1 / 2023-05-17 [(commits)](https://github.com/whitesmith/rubycritic/compare/v4.8.0...v4.8.1) diff --git a/test/fakefs_helper.rb b/test/fakefs_helper.rb index ff25faeb..69cb3250 100644 --- a/test/fakefs_helper.rb +++ b/test/fakefs_helper.rb @@ -5,9 +5,13 @@ module FakeFS class File < StringIO + # $VERBOSE = nil to suppress warnings when we overrie flock. + original_verbose = $VERBOSE + $VERBOSE = nil def flock(*) true end + $VERBOSE = original_verbose end end diff --git a/test/lib/rubycritic/commands/compare_test.rb b/test/lib/rubycritic/commands/compare_test.rb index db3d8e66..ab52e643 100644 --- a/test/lib/rubycritic/commands/compare_test.rb +++ b/test/lib/rubycritic/commands/compare_test.rb @@ -9,9 +9,13 @@ module RubyCritic module SourceControlSystem class Git < Base + # $VERBOSE = nil to suppress warnings when we overrie self.current_branch. + original_verbose = $VERBOSE + $VERBOSE = nil def self.current_branch 'feature_branch' end + $VERBOSE = original_verbose end end