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, #definition, #error, #expected, #got, #level
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:, definition:, error:, expected:, got:, negate:, 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, #error?, #inspect, #negate?, #passed?, #success?, #summary, #titre, #to_s
Constructor Details
#initialize(actual:, definition:, error:, expected:, got:, negate:, level:) ⇒ Pass
Initialize method.
47 48 49 50 51 52 53 54 55 |
# File 'lib/expresenter/pass.rb', line 47 def initialize(actual:, definition:, error:, expected:, got:, negate:, level:) @actual = actual @definition = definition @error = error @expected = expected @got = got @negate = negate @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.
101 102 103 104 105 106 107 108 109 |
# File 'lib/expresenter/pass.rb', line 101 def char if success? SUCCESS_CHAR elsif warning? WARNING_CHAR else INFO_CHAR end end |
#emoji ⇒ String
Express the result with one emoji.
114 115 116 117 118 119 120 121 122 |
# File 'lib/expresenter/pass.rb', line 114 def emoji if success? SUCCESS_EMOJI elsif warning? WARNING_EMOJI else INFO_EMOJI end end |
#failed? ⇒ Boolean
Did the test fail?
60 61 62 |
# File 'lib/expresenter/pass.rb', line 60 def failed? false end |
#failure? ⇒ Boolean
The state of failure.
67 68 69 |
# File 'lib/expresenter/pass.rb', line 67 def failure? false end |
#info? ⇒ Boolean
The state of info.
74 75 76 |
# File 'lib/expresenter/pass.rb', line 74 def info? !error.nil? end |
#to_sym ⇒ Symbol
Identify the state of the result.
88 89 90 91 92 93 94 95 96 |
# File 'lib/expresenter/pass.rb', line 88 def to_sym if success? :success elsif warning? :warning else :info end end |
#warning? ⇒ Boolean
The state of warning.
81 82 83 |
# File 'lib/expresenter/pass.rb', line 81 def warning? got.equal?(false) end |