Module: Vapir::Assertions
Overview
Verification methods
Instance Method Summary collapse
-
#verify(boolean, message = 'verify failed.') ⇒ Object
Log a failure if the boolean is true.
- #verify_equal(expected, actual, message = nil) ⇒ Object
- #verify_match(pattern, string, message = nil) ⇒ Object
Instance Method Details
#verify(boolean, message = 'verify failed.') ⇒ Object
Log a failure if the boolean is true. The message is the failure message logged. Whether true or false, the assertion count is incremented.
12 13 14 15 |
# File 'lib/vapir-common/testcase.rb', line 12 def verify boolean, = 'verify failed.' add_assertion add_failure .to_s, caller unless boolean end |
#verify_equal(expected, actual, message = nil) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/vapir-common/testcase.rb', line 17 def verify_equal expected, actual, =nil = (, <<EOT, expected, actual) <?> expected but was <?>. EOT verify(expected == actual, ) end |
#verify_match(pattern, string, message = nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/vapir-common/testcase.rb', line 24 def verify_match pattern, string, =nil pattern = case(pattern) when String Regexp.new(Regexp.escape(pattern)) else pattern end = (, "<?> expected to be =~\n<?>.", string, pattern) verify(string =~ pattern, ) end |