diff options
Diffstat (limited to 'spec/mspec/lib/mspec/utils/warnings.rb')
-rw-r--r-- | spec/mspec/lib/mspec/utils/warnings.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/spec/mspec/lib/mspec/utils/warnings.rb b/spec/mspec/lib/mspec/utils/warnings.rb index ef5e5c692c..4d23474236 100644 --- a/spec/mspec/lib/mspec/utils/warnings.rb +++ b/spec/mspec/lib/mspec/utils/warnings.rb @@ -1,6 +1,6 @@ require 'mspec/guards/version' -if RUBY_ENGINE == "ruby" and RUBY_VERSION >= "2.4.0" +if RUBY_ENGINE == "ruby" and ruby_version_is("2.4") ruby_version_is "2.4"..."2.5" do # Kernel#warn does not delegate to Warning.warn in 2.4 module Kernel @@ -16,9 +16,19 @@ if RUBY_ENGINE == "ruby" and RUBY_VERSION >= "2.4.0" end def Warning.warn(message) + if Thread.current[:in_mspec_complain_matcher] + return $stderr.write(message) + end + case message # $VERBOSE = true warnings - when /possibly useless use of (<|<=|==|>=|>|\+|-) in void context/ + when /(.+\.rb):(\d+):.+possibly useless use of (<|<=|==|>=|>) in void context/ + # Make sure there is a .should otherwise it is missing + line_nb = Integer($2) + unless File.exist?($1) and /\.should(_not)? (<|<=|==|>=|>)/ === File.readlines($1)[line_nb-1] + $stderr.write message + end + when /possibly useless use of (\+|-) in void context/ when /assigned but unused variable/ when /method redefined/ when /previous definition of/ |