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...
1 parent 10201b5 commit cd4fe89b0057edc2258876ad8c5f5e7e722f73c2 @zenspider zenspider committed Dec 13, 2011
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
View
@@ -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
Oops, something went wrong. Retry.

0 comments on commit cd4fe89

Please sign in to comment.