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, #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:, 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?, #negate?, #passed?, #success?, #summary, #titre, #to_s
Constructor Details
#initialize(actual:, definition:, error:, got:, negate:, level:) ⇒ Fail
Initialize method.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/expresenter/fail.rb', line 38 def initialize(actual:, definition:, error:, got:, negate:, level:) @actual = actual @definition = definition @error = error @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.
91 92 93 94 95 96 97 |
# File 'lib/expresenter/fail.rb', line 91 def char if failure? FAILURE_CHAR else ERROR_CHAR end end |
#emoji ⇒ String
Express the result with one emoji.
102 103 104 105 106 107 108 |
# File 'lib/expresenter/fail.rb', line 102 def emoji if failure? FAILURE_EMOJI else ERROR_EMOJI end end |
#failed? ⇒ Boolean
Did the test fail?
52 53 54 |
# File 'lib/expresenter/fail.rb', line 52 def failed? true end |
#failure? ⇒ Boolean
The state of failure.
59 60 61 |
# File 'lib/expresenter/fail.rb', line 59 def failure? !error? end |
#info? ⇒ Boolean
The state of info.
66 67 68 |
# File 'lib/expresenter/fail.rb', line 66 def info? false end |
#to_sym ⇒ Symbol
Identify the state of the result.
80 81 82 83 84 85 86 |
# File 'lib/expresenter/fail.rb', line 80 def to_sym if failure? :failure else :error end end |
#warning? ⇒ Boolean
The state of warning.
73 74 75 |
# File 'lib/expresenter/fail.rb', line 73 def warning? false end |