Skip to content
Permalink
Browse files

- Fixed error message on specs when 2+ args and custom message provid…

…ed. (chastell)

+ Cleaned up consistency of msg handling on unary expectations.
+ infect_an_assertion no longer checks arity and better handles args.
+ Added a ton of tests on spec error message output.

[git-p4: depot-paths = "//src/minitest/dev/": change = 6800]
  • Loading branch information...
zenspider committed Dec 13, 2011
1 parent 7934ac2 commit 0ccc4ab28df67e8566a3d202119f48b0575fe52f
Showing with 246 additions and 60 deletions.
  1. +10 −7 lib/minitest/spec.rb
  2. +216 −41 test/test_minitest_spec.rb
  3. +20 −12 test/test_minitest_unit.rb
@@ -7,11 +7,14 @@ def infect_an_assertion meth, new_name, dont_flip = false # :nodoc:
# warn "%-22p -> %p %p" % [meth, new_name, dont_flip]
self.class_eval <<-EOM
def #{new_name} *args
return MiniTest::Spec.current.#{meth}(*args, &self) if
Proc === self
return MiniTest::Spec.current.#{meth}(args.first, self) if
args.size == 1 unless #{!!dont_flip}
return MiniTest::Spec.current.#{meth}(self, *args)
case
when Proc === self then
MiniTest::Spec.current.#{meth}(*args, &self)
when #{!!dont_flip} then
MiniTest::Spec.current.#{meth}(self, *args)
else
MiniTest::Spec.current.#{meth}(args.first, self, *args[1..-1])
end
end
EOM
end
@@ -328,7 +331,7 @@ module MiniTest::Expectations
#
# :method: must_be_nil

infect_an_assertion :assert_nil, :must_be_nil
infect_an_assertion :assert_nil, :must_be_nil, :unary

##
# See MiniTest::Assertions#assert_operator
@@ -489,7 +492,7 @@ module MiniTest::Expectations
#
# :method: wont_be_nil

infect_an_assertion :refute_nil, :wont_be_nil
infect_an_assertion :refute_nil, :wont_be_nil, :unary

##
# See MiniTest::Assertions#refute_operator

0 comments on commit 0ccc4ab

Please sign in to comment.
You can’t perform that action at this time.