Module: Kernel
- Defined in:
- lib/kernel_extensions.rb
Defined Under Namespace
Constant Summary collapse
- METHODS_WITH_INLINE_TESTS =
[]
- METHODS_THAT_NEED_TESTS =
[]
- RUN_TESTS_IN_THIS_ENVIRONMENT =
true
Instance Method Summary collapse
- #assert(some_statement, description = '') ⇒ Object
- #assert_divisible_by(lhs, rhs, description = '') ⇒ Object
- #assert_equal(lhs, rhs, description = '') ⇒ Object
- #assert_greater_than(lhs, rhs, description = '') ⇒ Object
- #assert_less_than(lhs, rhs, description = '') ⇒ Object
- #assert_not_equal(lhs, rhs, description = '') ⇒ Object
- #tested(method_name, _ignored, &inline_test_block) ⇒ Object
- #tests ⇒ Object
-
#untested(method_name) ⇒ Object
This is just syntax sugar for decorating methods that are untested / need tests.
Instance Method Details
#assert(some_statement, description = '') ⇒ Object
26 27 28 29 30 31 |
# File 'lib/kernel_extensions.rb', line 26 def assert(some_statement, description = '') passed = !!some_statement raise InlineTestFailure.new('assert', some_statement, nil, description) unless passed passed end |
#assert_divisible_by(lhs, rhs, description = '') ⇒ Object
61 62 63 64 65 66 |
# File 'lib/kernel_extensions.rb', line 61 def assert_divisible_by(lhs, rhs, description = '') passed = !!flexible_assert(lhs, rhs, "[lhs] % [rhs] == 0") raise InlineTestFailure.new('assert_divisible_by', lhs, rhs, description) unless passed passed end |
#assert_equal(lhs, rhs, description = '') ⇒ Object
33 34 35 36 37 38 |
# File 'lib/kernel_extensions.rb', line 33 def assert_equal(lhs, rhs, description = '') passed = !!flexible_assert(lhs, rhs, "[lhs] == [rhs]") raise InlineTestFailure.new('assert_equal', lhs, rhs, description) unless passed passed end |
#assert_greater_than(lhs, rhs, description = '') ⇒ Object
54 55 56 57 58 59 |
# File 'lib/kernel_extensions.rb', line 54 def assert_greater_than(lhs, rhs, description = '') passed = !!flexible_assert(lhs, rhs, "[lhs] > [rhs]") raise InlineTestFailure.new('assert_greater_than', lhs, rhs, description) unless passed passed end |
#assert_less_than(lhs, rhs, description = '') ⇒ Object
47 48 49 50 51 52 |
# File 'lib/kernel_extensions.rb', line 47 def assert_less_than(lhs, rhs, description = '') passed = !!flexible_assert(lhs, rhs, "[lhs] < [rhs]") raise InlineTestFailure.new('assert_less_than', lhs, rhs, description) unless passed passed end |
#assert_not_equal(lhs, rhs, description = '') ⇒ Object
40 41 42 43 44 45 |
# File 'lib/kernel_extensions.rb', line 40 def assert_not_equal(lhs, rhs, description = '') passed = !!flexible_assert(lhs, rhs, "[lhs] != [rhs]") raise InlineTestFailure.new('assert_not_equal', lhs, rhs, description) unless passed passed end |
#tested(method_name, _ignored, &inline_test_block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/kernel_extensions.rb', line 7 def tested(method_name, _ignored, &inline_test_block) return unless RUN_TESTS_IN_THIS_ENVIRONMENT method = method_ref(method_name) # Register the method's tests to be run with InlineTests method.inline_tests = inline_test_block METHODS_WITH_INLINE_TESTS << method method end |
#tests ⇒ Object
18 |
# File 'lib/kernel_extensions.rb', line 18 def tests; end |
#untested(method_name) ⇒ Object
This is just syntax sugar for decorating methods that are untested / need tests
21 22 23 24 |
# File 'lib/kernel_extensions.rb', line 21 def untested(method_name) method = method_ref(method_name) METHODS_THAT_NEED_TESTS.push method end |