Module: Sus::Output::Messages
Constant Summary collapse
- PASSED_PREFIX =
[:passed, "✓ "].freeze
- FAILED_PREFIX =
[:failed, "✗ "].freeze
Instance Method Summary collapse
-
#assert(condition, orientation, message, backtrace) ⇒ Object
If the orientation is true, and the test passed, then it is a successful outcome.
- #error(error, identity, prefix = error_prefix) ⇒ Object
- #error_prefix ⇒ Object
- #fail_prefix(orientation) ⇒ Object
- #inform(message, identity) ⇒ Object
- #inform_prefix ⇒ Object
- #pass_prefix(orientation) ⇒ Object
- #skip(reason, identity) ⇒ Object
- #skip_prefix ⇒ Object
Instance Method Details
#assert(condition, orientation, message, backtrace) ⇒ Object
If the orientation is true, and the test passed, then it is a successful outcome. If the orientation is false, and the test failed, then it is a successful outcome. Otherwise, it is a failed outcome.
37 38 39 40 41 42 43 |
# File 'lib/sus/output/messages.rb', line 37 def assert(condition, orientation, , backtrace) if condition self.puts(:indent, *pass_prefix(orientation), , backtrace) else self.puts(:indent, *fail_prefix(orientation), , backtrace) end end |
#error(error, identity, prefix = error_prefix) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/sus/output/messages.rb', line 57 def error(error, identity, prefix = error_prefix) lines = error..split(/\r?\n/) self.puts(:indent, *prefix, error.class, ": ", lines.shift) lines.each do |line| self.puts(:indent, line) end self.write(Output::Backtrace.for(error, identity)) if cause = error.cause self.error(cause, identity, ["Caused by ", :errored]) end end |
#error_prefix ⇒ Object
53 54 55 |
# File 'lib/sus/output/messages.rb', line 53 def error_prefix [:errored, "⚠ "] end |
#fail_prefix(orientation) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/sus/output/messages.rb', line 21 def fail_prefix(orientation) if orientation FAILED_PREFIX else PASSED_PREFIX end end |
#inform(message, identity) ⇒ Object
77 78 79 |
# File 'lib/sus/output/messages.rb', line 77 def inform(, identity) self.puts(:indent, :inform, inform_prefix, ) end |
#inform_prefix ⇒ Object
73 74 75 |
# File 'lib/sus/output/messages.rb', line 73 def inform_prefix "ℹ " end |
#pass_prefix(orientation) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/sus/output/messages.rb', line 13 def pass_prefix(orientation) if orientation PASSED_PREFIX else FAILED_PREFIX end end |
#skip(reason, identity) ⇒ Object
49 50 51 |
# File 'lib/sus/output/messages.rb', line 49 def skip(reason, identity) self.puts(:indent, :skipped, skip_prefix, reason) end |
#skip_prefix ⇒ Object
45 46 47 |
# File 'lib/sus/output/messages.rb', line 45 def skip_prefix "⏸ " end |