Module: MiniAssert::Assertable
- Included in:
- TestCase
- Defined in:
- lib/mini_assert/assertable.rb
Overview
Assertion methods
Instance Method Summary collapse
- #assert(expression, message = 'Expected a truthy value') ⇒ Object
- #assert_equal(expected, value) ⇒ Object
- #assert_exception(exception) ⇒ Object
Instance Method Details
#assert(expression, message = 'Expected a truthy value') ⇒ Object
8 9 10 |
# File 'lib/mini_assert/assertable.rb', line 8 def assert(expression, = 'Expected a truthy value') raise AssertionError, unless expression end |
#assert_equal(expected, value) ⇒ Object
12 13 14 |
# File 'lib/mini_assert/assertable.rb', line 12 def assert_equal(expected, value) assert(expected == value, "Expected #{expected.inspect} to equal #{value.inspect}") end |
#assert_exception(exception) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/mini_assert/assertable.rb', line 16 def assert_exception(exception) yield assert(false, "Expected #{exception} but nothing was raised") rescue => e assert(e.class == exception, "Expected #{exception} got #{e.class}") end |