Exception: Expresenter::Fail
- Inherits:
-
StandardError
- Object
- StandardError
- Expresenter::Fail
- Includes:
- Common
- Defined in:
- lib/expresenter/fail.rb
Overview
The class that is responsible for reporting that an expectation is false.
Constant Summary collapse
- FAILURE_CHAR =
"F"- FAILURE_EMOJI =
"❌"- ERROR_CHAR =
"E"- ERROR_EMOJI =
"💥"
Constants included from Common
Instance Attribute Summary
Attributes included from Common
#actual, #error, #expected, #got, #level, #matcher
Class Method Summary collapse
Instance Method Summary collapse
-
#char ⇒ String
Express the result with one char.
-
#emoji ⇒ String
Express the result with one emoji.
-
#failed? ⇒ Boolean
Did the test fail?.
-
#failure? ⇒ Boolean
The state of failure.
-
#info? ⇒ Boolean
The state of info.
-
#initialize(actual:, error:, expected:, got:, negate:, valid:, matcher:, level:) ⇒ Fail
constructor
Initialize method.
-
#to_sym ⇒ Symbol
Identify the state of the result.
-
#warning? ⇒ Boolean
The state of warning.
Methods included from Common
#colored_char, #colored_string, #definition, #error?, #inspect, #negate?, #passed?, #success?, #summary, #titre, #to_s, #valid?
Constructor Details
#initialize(actual:, error:, expected:, got:, negate:, valid:, matcher:, level:) ⇒ Fail
Initialize method.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/expresenter/fail.rb', line 33 def initialize(actual:, error:, expected:, got:, negate:, valid:, matcher:, level:) @actual = actual @error = error @expected = expected @got = got @negate = negate @valid = valid @matcher = matcher @level = level super(to_s) end |
Class Method Details
.with(**details) ⇒ Object
18 19 20 |
# File 'lib/expresenter/fail.rb', line 18 def self.with(**details) raise new(**details) end |
Instance Method Details
#char ⇒ String
Express the result with one char.
90 91 92 93 94 95 96 |
# File 'lib/expresenter/fail.rb', line 90 def char if failure? FAILURE_CHAR else ERROR_CHAR end end |
#emoji ⇒ String
Express the result with one emoji.
101 102 103 104 105 106 107 |
# File 'lib/expresenter/fail.rb', line 101 def emoji if failure? FAILURE_EMOJI else ERROR_EMOJI end end |
#failed? ⇒ Boolean
Did the test fail?
51 52 53 |
# File 'lib/expresenter/fail.rb', line 51 def failed? true end |
#failure? ⇒ Boolean
The state of failure.
58 59 60 |
# File 'lib/expresenter/fail.rb', line 58 def failure? !error? end |
#info? ⇒ Boolean
The state of info.
65 66 67 |
# File 'lib/expresenter/fail.rb', line 65 def info? false end |
#to_sym ⇒ Symbol
Identify the state of the result.
79 80 81 82 83 84 85 |
# File 'lib/expresenter/fail.rb', line 79 def to_sym if failure? :failure else :error end end |
#warning? ⇒ Boolean
The state of warning.
72 73 74 |
# File 'lib/expresenter/fail.rb', line 72 def warning? false end |