Module: InlineTester::Assertions
- Defined in:
- lib/assertions.rb
Instance Method Summary collapse
- #assert(boolean, message = nil) ⇒ Object
- #assert_matches(string, pattern, message = nil) ⇒ Object
- #assert_something_raised(message = nil, &block) ⇒ Object
- #refute(boolean, message = nil) ⇒ Object
- #skip(message = nil, &block) ⇒ Object
- #todo(message = nil) ⇒ Object
Instance Method Details
#assert(boolean, message = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/assertions.rb', line 8 def assert boolean, =nil unless boolean # MESSAGE::: Assertion did not pass. $stdout.print( || "Expected a truthy value, but instead got #{boolean}") stack_trace_print else end end |
#assert_matches(string, pattern, message = nil) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/assertions.rb', line 42 def assert_matches string, pattern, =nil $__stack_+=1 assert(string =~ pattern, || "Expected #{string} to match #{pattern}, but it did not.") $__stack_-=1 end |
#assert_something_raised(message = nil, &block) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/assertions.rb', line 30 def assert_something_raised =nil, &block begin yield # Message::: Nothing raised. $stdout.print( || "Expected #{block} to raise an Exception, but it did not.") stack_trace_print rescue => e end end |
#refute(boolean, message = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/assertions.rb', line 19 def refute boolean, =nil if boolean # MESSAGE::: Refution did not pass. $stdout.print( || "Expected a falsy value, but instead got #{boolean}") stack_trace_print else end end |
#skip(message = nil, &block) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/assertions.rb', line 49 def skip =nil, &block $stdout.print || "Skipped assertion." if block_given? yield end end |
#todo(message = nil) ⇒ Object
56 57 58 59 |
# File 'lib/assertions.rb', line 56 def todo =nil $stdout.print || "TODO!" stack_trace_print end |