mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
assertions.rb: last match in assert_raise_with_message
* lib/test/unit/assertions.rb (assert_raise_with_message): set caller's last match if expected is a Regexp. * test/ruby/test_arity.rb (err_mess): use assert_raise_with_message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3ba2006aa4
commit
287d2adab0
2 changed files with 10 additions and 5 deletions
|
@ -3,7 +3,7 @@ require 'test/unit'
|
|||
class TestArity < Test::Unit::TestCase
|
||||
def err_mess(method_proc = nil, argc = 0)
|
||||
args = (1..argc).to_a
|
||||
err = assert_raise(ArgumentError) do
|
||||
assert_raise_with_message(ArgumentError, /wrong number of arguments \((.*)\)/) do
|
||||
case method_proc
|
||||
when nil
|
||||
yield
|
||||
|
@ -13,8 +13,6 @@ class TestArity < Test::Unit::TestCase
|
|||
method_proc.call(*args)
|
||||
end
|
||||
end
|
||||
s = err.to_s
|
||||
assert s =~ /wrong number of arguments \((.*)\)/, "Unexpected ArgumentError's message: #{s}"
|
||||
$1
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue