diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-16 13:51:15 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-16 13:51:15 +0000 |
commit | 4cfbc59dc32fbbf93be5839e3d5b4c4af6051a70 (patch) | |
tree | 82237a401c9e8b885825255f8854c04052b1eff4 /spec | |
parent | 8dd82a3e1e13d94f695e88d56a62a78bdcd961a4 (diff) | |
download | ruby-4cfbc59dc32fbbf93be5839e3d5b4c4af6051a70.tar.gz |
Multiple exception classes at raise_error
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec')
-rw-r--r-- | spec/mspec/lib/mspec/matchers/raise_error.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/spec/mspec/lib/mspec/matchers/raise_error.rb b/spec/mspec/lib/mspec/matchers/raise_error.rb index a5d6e01ec9..b8ff560499 100644 --- a/spec/mspec/lib/mspec/matchers/raise_error.rb +++ b/spec/mspec/lib/mspec/matchers/raise_error.rb @@ -2,7 +2,7 @@ require 'mspec/utils/deprecate' class RaiseErrorMatcher def initialize(exception, message, &block) - @exception = exception + @exception = Array(exception) @message = message @block = block end @@ -19,7 +19,7 @@ class RaiseErrorMatcher end def matching_exception?(exc) - return false unless @exception === exc + return false unless @exception.any? {|exception_class| exception_class === exc} if @message then case @message when String @@ -36,6 +36,9 @@ class RaiseErrorMatcher end def exception_class_and_message(exception_class, message) + if Array === exception_class and exception_class.size == 1 + exception_class = exception_class[0] + end if message "#{exception_class} (#{message})" else @@ -65,7 +68,7 @@ class RaiseErrorMatcher def negative_failure_message message = ["Expected to not get #{format_expected_exception}", ""] - unless @actual.class == @exception + unless @exception.include?(@actual.class) message[1] = "but got #{format_exception(@actual)}" end message |