Module: Tet::Messages
- Defined in:
- lib/tet.rb
Overview
Tracks and reports messages for each test
Constant Summary collapse
- Labels =
[]
- Results =
[]
- Errors =
[]
Class Method Summary collapse
-
.erred(caught, expected = nil) ⇒ Object
Call when an assertion has passed.
-
.error_report ⇒ Object
Returns a string with details about all errors.
-
.failed ⇒ Object
Call when an assertion has failed.
-
.failure_report ⇒ Object
Returns a string with details about all failed tests.
-
.with_label(label) ⇒ Object
Add a label to all subsequent messages.
Class Method Details
.erred(caught, expected = nil) ⇒ Object
Call when an assertion has passed
228 229 230 231 232 233 234 235 236 |
# File 'lib/tet.rb', line 228 def erred caught, expected = nil number = Stats::Counts[:erred] label = "EXCEPTION_#{number}" label << " (expected: #{expected})" if expected with_label(label) { add_result! } Errors.push((caught, number)) end |
.error_report ⇒ Object
Returns a string with details about all errors
244 245 246 |
# File 'lib/tet.rb', line 244 def error_report Errors.join("\n\n") end |
.failed ⇒ Object
Call when an assertion has failed
223 224 225 |
# File 'lib/tet.rb', line 223 def failed add_result! end |
.failure_report ⇒ Object
Returns a string with details about all failed tests
239 240 241 |
# File 'lib/tet.rb', line 239 def failure_report Results.join(?\n) end |
.with_label(label) ⇒ Object
Add a label to all subsequent messages
215 216 217 218 219 220 |
# File 'lib/tet.rb', line 215 def with_label label Labels.push(label) yield ensure Labels.pop end |