summaryrefslogtreecommitdiff
path: root/spec/mspec/lib
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-20 20:38:27 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-20 20:38:27 +0000
commit58573c33e4720315ed27491e31dcc22892e1ce95 (patch)
tree336d0c3c193555a82e0d2ad8175e7f7bfcc76b30 /spec/mspec/lib
parent1c53f86bd9701abd6c6d3a787541e5c408f5aef9 (diff)
Update to ruby/mspec@e9a482d
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/mspec/lib')
-rw-r--r--spec/mspec/lib/mspec/matchers/complain.rb19
-rw-r--r--spec/mspec/lib/mspec/matchers/raise_error.rb7
-rw-r--r--spec/mspec/lib/mspec/utils/warnings.rb2
3 files changed, 19 insertions, 9 deletions
diff --git a/spec/mspec/lib/mspec/matchers/complain.rb b/spec/mspec/lib/mspec/matchers/complain.rb
index 4bcb255040..22b8be17e1 100644
--- a/spec/mspec/lib/mspec/matchers/complain.rb
+++ b/spec/mspec/lib/mspec/matchers/complain.rb
@@ -1,8 +1,17 @@
require 'mspec/helpers/io'
class ComplainMatcher
- def initialize(complaint)
- @complaint = complaint
+ def initialize(complaint = nil, options = nil)
+ # the proper solution is to use double splat operator e.g.
+ # def initialize(complaint = nil, **options)
+ # but we are trying to minimize language features required to run MSpec
+ if complaint.is_a?(Hash)
+ @complaint = nil
+ @options = complaint
+ else
+ @complaint = complaint
+ @options = options || {}
+ end
end
def matches?(proc)
@@ -10,7 +19,7 @@ class ComplainMatcher
@verbose = $VERBOSE
begin
err = $stderr = IOStub.new
- $VERBOSE = false
+ $VERBOSE = @options.key?(:verbose) ? @options[:verbose] : false
Thread.current[:in_mspec_complain_matcher] = true
proc.call
ensure
@@ -54,7 +63,7 @@ class ComplainMatcher
end
module MSpecMatchers
- private def complain(complaint=nil)
- ComplainMatcher.new(complaint)
+ private def complain(complaint = nil, options = nil)
+ ComplainMatcher.new(complaint, options)
end
end
diff --git a/spec/mspec/lib/mspec/matchers/raise_error.rb b/spec/mspec/lib/mspec/matchers/raise_error.rb
index a051ea12f7..8350e25794 100644
--- a/spec/mspec/lib/mspec/matchers/raise_error.rb
+++ b/spec/mspec/lib/mspec/matchers/raise_error.rb
@@ -12,6 +12,9 @@ class RaiseErrorMatcher
rescue Exception => actual
@actual = actual
if matching_exception?(actual)
+ # The block has its own expectations and will throw an exception if it fails
+ @block[actual] if @block
+
return true
else
raise actual
@@ -20,6 +23,7 @@ class RaiseErrorMatcher
def matching_exception?(exc)
return false unless @exception === exc
+
if @message then
case @message
when String
@@ -29,9 +33,6 @@ class RaiseErrorMatcher
end
end
- # The block has its own expectations and will throw an exception if it fails
- @block[exc] if @block
-
return true
end
diff --git a/spec/mspec/lib/mspec/utils/warnings.rb b/spec/mspec/lib/mspec/utils/warnings.rb
index 4d23474236..7c2bc6fe88 100644
--- a/spec/mspec/lib/mspec/utils/warnings.rb
+++ b/spec/mspec/lib/mspec/utils/warnings.rb
@@ -51,7 +51,7 @@ if RUBY_ENGINE == "ruby" and ruby_version_is("2.4")
when /hash\/shared\/index\.rb:\d+: warning: Hash#index is deprecated; use Hash#key/
when /env\/shared\/key\.rb:\d+: warning: ENV\.index is deprecated; use ENV\.key/
when /exponent(_spec)?\.rb:\d+: warning: in a\*\*b, b may be too big/
- when /enumerator\/(new|initialize_spec)\.rb:\d+: warning: Enumerator\.new without a block is deprecated/
+ when /enumerator\/(new_spec|initialize_spec)\.rb:\d+: warning: Enumerator\.new without a block is deprecated/
else
$stderr.write message
end