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.
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, #maybe_negate, #negate?, #passed?, #success?, #summary, #titre, #to_s, #valid?
Constructor Details
#initialize(actual:, error:, expected:, got:, negate:, valid:, matcher:, level:) ⇒ Fail
Initialize method.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/expresenter/fail.rb', line 27 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
12 13 14 |
# File 'lib/expresenter/fail.rb', line 12 def self.with(**details) raise new(**details) end |
Instance Method Details
#char ⇒ String
Express the result with one char.
84 85 86 87 88 89 90 |
# File 'lib/expresenter/fail.rb', line 84 def char if failure? "F" else "E" end end |
#emoji ⇒ String
Express the result with one emoji.
95 96 97 98 99 100 101 |
# File 'lib/expresenter/fail.rb', line 95 def emoji if failure? "❌" else "💥" end end |
#failed? ⇒ Boolean
Did the test fail?
45 46 47 |
# File 'lib/expresenter/fail.rb', line 45 def failed? true end |
#failure? ⇒ Boolean
The state of failure.
52 53 54 |
# File 'lib/expresenter/fail.rb', line 52 def failure? !error? end |
#info? ⇒ Boolean
The state of info.
59 60 61 |
# File 'lib/expresenter/fail.rb', line 59 def info? false end |
#to_sym ⇒ Symbol
Identify the state of the result.
73 74 75 76 77 78 79 |
# File 'lib/expresenter/fail.rb', line 73 def to_sym if failure? :failure else :error end end |
#warning? ⇒ Boolean
The state of warning.
66 67 68 |
# File 'lib/expresenter/fail.rb', line 66 def warning? false end |