summaryrefslogtreecommitdiff
path: root/spec/mspec/lib/mspec/utils
diff options
context:
space:
mode:
Diffstat (limited to 'spec/mspec/lib/mspec/utils')
-rw-r--r--spec/mspec/lib/mspec/utils/script.rb4
-rw-r--r--spec/mspec/lib/mspec/utils/warnings.rb19
2 files changed, 23 insertions, 0 deletions
diff --git a/spec/mspec/lib/mspec/utils/script.rb b/spec/mspec/lib/mspec/utils/script.rb
index 1c7d0aeb52..0c8922c4a8 100644
--- a/spec/mspec/lib/mspec/utils/script.rb
+++ b/spec/mspec/lib/mspec/utils/script.rb
@@ -38,6 +38,10 @@ class MSpecScript
end
def initialize
+ if RUBY_VERSION < '2.2'
+ abort "MSpec needs Ruby 2.2 or more recent"
+ end
+
config[:formatter] = nil
config[:includes] = []
config[:excludes] = []
diff --git a/spec/mspec/lib/mspec/utils/warnings.rb b/spec/mspec/lib/mspec/utils/warnings.rb
index 74c7f88a52..ef5e5c692c 100644
--- a/spec/mspec/lib/mspec/utils/warnings.rb
+++ b/spec/mspec/lib/mspec/utils/warnings.rb
@@ -4,6 +4,7 @@ if RUBY_ENGINE == "ruby" and RUBY_VERSION >= "2.4.0"
ruby_version_is "2.4"..."2.5" do
# Kernel#warn does not delegate to Warning.warn in 2.4
module Kernel
+ remove_method :warn
def warn(*messages)
return if $VERBOSE == nil or messages.empty?
msg = messages.join("\n")
@@ -16,6 +17,24 @@ if RUBY_ENGINE == "ruby" and RUBY_VERSION >= "2.4.0"
def Warning.warn(message)
case message
+ # $VERBOSE = true warnings
+ when /possibly useless use of (<|<=|==|>=|>|\+|-) in void context/
+ when /assigned but unused variable/
+ when /method redefined/
+ when /previous definition of/
+ when /instance variable @.+ not initialized/
+ when /statement not reached/
+ when /shadowing outer local variable/
+ when /setting Encoding.default_(in|ex)ternal/
+ when /unknown (un)?pack directive/
+ when /(un)?trust(ed\?)? is deprecated/
+ when /\.exists\? is a deprecated name/
+ when /Float .+ out of range/
+ when /passing a block to String#(bytes|chars|codepoints|lines) is deprecated/
+ when /core\/string\/modulo_spec\.rb:\d+: warning: too many arguments for format string/
+ when /regexp\/shared\/new_ascii(_8bit)?\.rb:\d+: warning: Unknown escape .+ is ignored/
+
+ # $VERBOSE = false warnings
when /constant ::(Fixnum|Bignum) is deprecated/
when /\/(argf|io|stringio)\/.+(ARGF|IO)#(lines|chars|bytes|codepoints) is deprecated/
when /Thread\.exclusive is deprecated.+\n.+thread\/exclusive_spec\.rb/