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, #definition, #error, #expected, #got, #level
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:, definition:, error:, expected:, got:, negate:, 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, #error?, #inspect, #negate?, #passed?, #success?, #summary, #titre, #to_s
Constructor Details
#initialize(actual:, definition:, error:, expected:, got:, negate:, level:) ⇒ Fail
Initialize method.
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/expresenter/fail.rb', line 39 def initialize(actual:, definition:, error:, expected:, got:, negate:, level:) @actual = actual @definition = definition @error = error @expected = expected @got = got @negate = negate @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.
93 94 95 96 97 98 99 |
# File 'lib/expresenter/fail.rb', line 93 def char if failure? FAILURE_CHAR else ERROR_CHAR end end |
#emoji ⇒ String
Express the result with one emoji.
104 105 106 107 108 109 110 |
# File 'lib/expresenter/fail.rb', line 104 def emoji if failure? FAILURE_EMOJI else ERROR_EMOJI end end |
#failed? ⇒ Boolean
Did the test fail?
54 55 56 |
# File 'lib/expresenter/fail.rb', line 54 def failed? true end |
#failure? ⇒ Boolean
The state of failure.
61 62 63 |
# File 'lib/expresenter/fail.rb', line 61 def failure? !error? end |
#info? ⇒ Boolean
The state of info.
68 69 70 |
# File 'lib/expresenter/fail.rb', line 68 def info? false end |
#to_sym ⇒ Symbol
Identify the state of the result.
82 83 84 85 86 87 88 |
# File 'lib/expresenter/fail.rb', line 82 def to_sym if failure? :failure else :error end end |
#warning? ⇒ Boolean
The state of warning.
75 76 77 |
# File 'lib/expresenter/fail.rb', line 75 def warning? false end |