module MiniTest::Assertions
Public Instance Methods
assert_between(*args)
click to toggle source
# File lib/minitest-extra-assertions.rb, line 24 def assert_between(*args) hi, lo, exp, msg = if args.first.is_a?(Range) [args.first.begin, args.first.end, args[1], args[2]] else args[0..3] end msg = message(msg) { "Expected #{mu_pp(exp)} to be between #{mu_pp(lo)} and #{mu_pp(hi)}" } assert (lo < exp && exp < hi) || (hi < exp && exp < lo), msg end
assert_false(obj, msg = nil)
click to toggle source
# File lib/minitest-extra-assertions.rb, line 3 def assert_false obj, msg = nil msg = message(msg) { "<false> expected but was #{mu_pp(obj)}" } assert obj == false, msg end
assert_match(exp, act, msg = nil)
click to toggle source
This actually conflicts with behavior in minitest proper; this mimics the old Test::Unit implementation, relying on the #=~ method of the actual object. Minitest calls #=~ on the matcher instead, which is honestly better by the POLS but makes it much more difficult to test objects that have custom #=~ implementations.
# File lib/minitest-extra-assertions.rb, line 17 def assert_match exp, act, msg = nil msg = message(msg) { "Expected #{mu_pp(exp)} to match #{mu_pp(act)}" } assert_respond_to act, "=~" exp = Regexp.new(Regexp.escape(exp)) if String === exp assert act =~ exp, msg end
assert_true(obj, msg = nil)
click to toggle source
# File lib/minitest-extra-assertions.rb, line 8 def assert_true obj, msg = nil msg = message(msg) { "<true> expected but was #{mu_pp(obj)}" } assert obj == true, msg end