Class: Expresenter::Pass
- Inherits:
-
Object
- Object
- Expresenter::Pass
- Includes:
- Common
- Defined in:
- lib/expresenter/pass.rb
Overview
The class that is responsible for reporting that an expectation is true.
Constant Summary collapse
- INFO_CHAR =
Char representing an info.
"I"- INFO_EMOJI =
Emoji representing an info.
"💡"- SUCCESS_CHAR =
Char representing a success.
"."- SUCCESS_EMOJI =
Emoji representing a success.
"✅"- WARNING_CHAR =
Char representing a warning.
"W"- WARNING_EMOJI =
Emoji representing a warning.
"⚠️"
Constants included from Common
Instance Attribute Summary
Attributes included from Common
#actual, #error, #expected, #got, #level, #matcher
Class Method Summary collapse
-
.with(**details) ⇒ Pass
A passed spec instance.
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:) ⇒ Pass
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:) ⇒ Pass
Initialize method.
46 47 48 49 50 51 52 53 54 |
# File 'lib/expresenter/pass.rb', line 46 def initialize(actual:, error:, expected:, got:, negate:, matcher:, level:) @actual = actual @error = error @expected = expected @got = got @negate = negate @matcher = matcher @level = level end |
Class Method Details
.with(**details) ⇒ Pass
Returns A passed spec instance.
30 31 32 |
# File 'lib/expresenter/pass.rb', line 30 def self.with(**details) new(**details) end |
Instance Method Details
#char ⇒ String
Express the result with one char.
100 101 102 103 104 105 106 107 108 |
# File 'lib/expresenter/pass.rb', line 100 def char if success? SUCCESS_CHAR elsif warning? WARNING_CHAR else INFO_CHAR end end |
#emoji ⇒ String
Express the result with one emoji.
113 114 115 116 117 118 119 120 121 |
# File 'lib/expresenter/pass.rb', line 113 def emoji if success? SUCCESS_EMOJI elsif warning? WARNING_EMOJI else INFO_EMOJI end end |
#failed? ⇒ Boolean
Did the test fail?
59 60 61 |
# File 'lib/expresenter/pass.rb', line 59 def failed? false end |
#failure? ⇒ Boolean
The state of failure.
66 67 68 |
# File 'lib/expresenter/pass.rb', line 66 def failure? false end |
#info? ⇒ Boolean
The state of info.
73 74 75 |
# File 'lib/expresenter/pass.rb', line 73 def info? !error.nil? end |
#to_sym ⇒ Symbol
Identify the state of the result.
87 88 89 90 91 92 93 94 95 |
# File 'lib/expresenter/pass.rb', line 87 def to_sym if success? :success elsif warning? :warning else :info end end |
#warning? ⇒ Boolean
The state of warning.
80 81 82 |
# File 'lib/expresenter/pass.rb', line 80 def warning? got.equal?(false) end |