ruby-changes:46637
From: nobu <ko1@a...>
Date: Tue, 16 May 2017 22:51:19 +0900 (JST)
Subject: [ruby-changes:46637] nobu:r58752 (trunk): Multiple exception classes at raise_error
nobu 2017-05-16 22:51:15 +0900 (Tue, 16 May 2017) New Revision: 58752 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58752 Log: Multiple exception classes at raise_error Modified files: trunk/spec/mspec/lib/mspec/matchers/raise_error.rb Index: spec/mspec/lib/mspec/matchers/raise_error.rb =================================================================== --- spec/mspec/lib/mspec/matchers/raise_error.rb (revision 58751) +++ spec/mspec/lib/mspec/matchers/raise_error.rb (revision 58752) @@ -2,7 +2,7 @@ require 'mspec/utils/deprecate' https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/matchers/raise_error.rb#L2 class RaiseErrorMatcher def initialize(exception, message, &block) - @exception = exception + @exception = Array(exception) @message = message @block = block end @@ -19,7 +19,7 @@ class RaiseErrorMatcher https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/matchers/raise_error.rb#L19 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 https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/matchers/raise_error.rb#L36 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 https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/matchers/raise_error.rb#L68 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/