Class: Neiltest::TestCase
- Inherits:
-
Object
- Object
- Neiltest::TestCase
- Defined in:
- lib/neiltest/test_case.rb
Defined Under Namespace
Classes: Result
Instance Attribute Summary collapse
-
#results ⇒ Object
Returns the value of attribute results.
Instance Method Summary collapse
- #assert(value, message = nil) ⇒ Object
- #assert_equal(expected, actual, message = nil) ⇒ Object
- #assert_not_equal(first, second, message = nil) ⇒ Object
-
#initialize ⇒ TestCase
constructor
A new instance of TestCase.
- #refute(value, message = nil) ⇒ Object
Constructor Details
#initialize ⇒ TestCase
Returns a new instance of TestCase.
19 20 21 22 |
# File 'lib/neiltest/test_case.rb', line 19 def initialize self.results = [] run end |
Instance Attribute Details
#results ⇒ Object
Returns the value of attribute results.
3 4 5 |
# File 'lib/neiltest/test_case.rb', line 3 def results @results end |
Instance Method Details
#assert(value, message = nil) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/neiltest/test_case.rb', line 24 def assert(value, = nil) if value add_result Result.new(type: :pass) else add_result Result.new(type: :fail, backtrace: caller, message: || "Expected a truthy but got #{value}") end end |
#assert_equal(expected, actual, message = nil) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/neiltest/test_case.rb', line 40 def assert_equal(expected, actual, = nil) if expected == actual add_result Result.new(type: :pass) else add_result Result.new(type: :fail, backtrace: caller, message: || "Expected #{expected} but got #{actual}") end end |
#assert_not_equal(first, second, message = nil) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/neiltest/test_case.rb', line 48 def assert_not_equal(first, second, = nil) if first != second add_result Result.new(type: :pass) else add_result Result.new(type: :fail, backtrace: caller, message: || "Expected #{first} to be different from #{second}") end end |