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 =
Char representing a failure.
"F"- FAILURE_EMOJI =
Emoji representing a failure.
"❌"- ERROR_CHAR =
Char representing an error.
"E"- ERROR_EMOJI =
Emoji representing an error.
"💥"
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:, 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
Constructor Details
#initialize(actual:, error:, expected:, got:, negate:, matcher:, level:) ⇒ Fail
Initialize method.
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/expresenter/fail.rb', line 38 def initialize(actual:, error:, expected:, got:, negate:, matcher:, level:) @actual = actual @error = error @expected = expected @got = got @negate = negate @matcher = matcher @level = level super(to_s) end |
Class Method Details
.with(**details) ⇒ Object
24 25 26 |
# File 'lib/expresenter/fail.rb', line 24 def self.with(**details) raise new(**details) end |
Instance Method Details
#char ⇒ String
Express the result with one char.
92 93 94 95 96 97 98 |
# File 'lib/expresenter/fail.rb', line 92 def char if failure? FAILURE_CHAR else ERROR_CHAR end end |
#emoji ⇒ String
Express the result with one emoji.
103 104 105 106 107 108 109 |
# File 'lib/expresenter/fail.rb', line 103 def emoji if failure? FAILURE_EMOJI else ERROR_EMOJI end end |
#failed? ⇒ Boolean
Did the test fail?
53 54 55 |
# File 'lib/expresenter/fail.rb', line 53 def failed? true end |
#failure? ⇒ Boolean
The state of failure.
60 61 62 |
# File 'lib/expresenter/fail.rb', line 60 def failure? !error? end |
#info? ⇒ Boolean
The state of info.
67 68 69 |
# File 'lib/expresenter/fail.rb', line 67 def info? false end |
#to_sym ⇒ Symbol
Identify the state of the result.
81 82 83 84 85 86 87 |
# File 'lib/expresenter/fail.rb', line 81 def to_sym if failure? :failure else :error end end |
#warning? ⇒ Boolean
The state of warning.
74 75 76 |
# File 'lib/expresenter/fail.rb', line 74 def warning? false end |