Class: Expresenter::Pass
- Inherits:
-
Object
- Object
- Expresenter::Pass
- Includes:
- Common
- Defined in:
- lib/expresenter/pass.rb
Overview
Class responsible for handling and reporting successful test expectations.
The Pass class represents test results that didn’t fail, but can be in different states:
-
Success: Test passed completely as expected
-
Warning: Test passed but with some concerns (typically for :SHOULD or :MAY requirements)
-
Info: Test passed but with additional information to note
Each state has its own character indicator, emoji, and color for easy visual identification in test output:
-
Success: “.” (green) ✅
-
Warning: “W” (yellow) ⚠️
-
Info: “I” (blue) 💡
Constant Summary collapse
- INFO_CHAR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Single character indicator for informational results.
"I"
- INFO_EMOJI =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Emoji indicator for informational results.
"💡"
- SUCCESS_CHAR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Single character indicator for successful results.
"."
- SUCCESS_EMOJI =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Emoji indicator for successful results.
"✅"
- WARNING_CHAR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Single character indicator for warning results.
"W"
- WARNING_EMOJI =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Emoji indicator for warning results.
"⚠️"
Constants included from Common
Instance Attribute Summary
Attributes included from Common
#actual, #definition, #error, #got, #level
Class Method Summary collapse
-
.with(**details) ⇒ Pass
Creates a new Pass instance with the given details.
Instance Method Summary collapse
-
#char ⇒ String
Returns a single character representing the result state.
-
#emoji ⇒ String
Returns an emoji representing the result state.
-
#failed? ⇒ false
Always returns false since this class represents passed tests.
-
#failure? ⇒ false
Pass results are never failures.
-
#info? ⇒ Boolean
Indicates if this is an informational result.
-
#initialize(actual:, definition:, error:, got:, negate:, level:) ⇒ Pass
constructor
Initializes a new Pass instance.
-
#to_sym ⇒ :success, ...
Returns the symbolic representation of the result state.
-
#warning? ⇒ Boolean
Indicates if this is a warning result.
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:) ⇒ Pass
Initializes a new Pass instance.
103 104 105 106 107 108 109 110 |
# File 'lib/expresenter/pass.rb', line 103 def initialize(actual:, definition:, error:, got:, negate:, level:) @actual = actual @definition = definition @error = error @got = got @negate = negate @level = level end |
Class Method Details
.with(**details) ⇒ Pass
Creates a new Pass instance with the given details.
89 90 91 |
# File 'lib/expresenter/pass.rb', line 89 def self.with(**details) new(**details) end |
Instance Method Details
#char ⇒ String
Returns a single character representing the result state.
156 157 158 159 160 161 162 163 164 |
# File 'lib/expresenter/pass.rb', line 156 def char if success? SUCCESS_CHAR elsif warning? WARNING_CHAR else INFO_CHAR end end |
#emoji ⇒ String
Returns an emoji representing the result state.
169 170 171 172 173 174 175 176 177 |
# File 'lib/expresenter/pass.rb', line 169 def emoji if success? SUCCESS_EMOJI elsif warning? WARNING_EMOJI else INFO_EMOJI end end |
#failed? ⇒ false
Always returns false since this class represents passed tests.
115 116 117 |
# File 'lib/expresenter/pass.rb', line 115 def failed? false end |
#failure? ⇒ false
Pass results are never failures.
122 123 124 |
# File 'lib/expresenter/pass.rb', line 122 def failure? false end |
#info? ⇒ Boolean
Indicates if this is an informational result.
129 130 131 |
# File 'lib/expresenter/pass.rb', line 129 def info? !error.nil? end |
#to_sym ⇒ :success, ...
Returns the symbolic representation of the result state.
143 144 145 146 147 148 149 150 151 |
# File 'lib/expresenter/pass.rb', line 143 def to_sym if success? :success elsif warning? :warning else :info end end |
#warning? ⇒ Boolean
Indicates if this is a warning result.
136 137 138 |
# File 'lib/expresenter/pass.rb', line 136 def warning? got.equal?(false) end |