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 =
"I"- INFO_EMOJI =
"💡"- SUCCESS_CHAR =
"."- SUCCESS_EMOJI =
"✅"- WARNING_CHAR =
"W"- WARNING_EMOJI =
"⚠️"
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:, valid:, 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, #valid?
Constructor Details
#initialize(actual:, error:, expected:, got:, negate:, valid:, matcher:, level:) ⇒ Pass
Initialize method.
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/expresenter/pass.rb', line 38 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 end |
Class Method Details
.with(**details) ⇒ Pass
Returns A passed spec instance.
21 22 23 |
# File 'lib/expresenter/pass.rb', line 21 def self.with(**details) new(**details) end |
Instance Method Details
#char ⇒ String
Express the result with one char.
95 96 97 98 99 100 101 102 103 |
# File 'lib/expresenter/pass.rb', line 95 def char if success? SUCCESS_CHAR elsif warning? WARNING_CHAR else INFO_CHAR end end |
#emoji ⇒ String
Express the result with one emoji.
108 109 110 111 112 113 114 115 116 |
# File 'lib/expresenter/pass.rb', line 108 def emoji if success? SUCCESS_EMOJI elsif warning? WARNING_EMOJI else INFO_EMOJI end end |
#failed? ⇒ Boolean
Did the test fail?
54 55 56 |
# File 'lib/expresenter/pass.rb', line 54 def failed? false end |
#failure? ⇒ Boolean
The state of failure.
61 62 63 |
# File 'lib/expresenter/pass.rb', line 61 def failure? false end |
#info? ⇒ Boolean
The state of info.
68 69 70 |
# File 'lib/expresenter/pass.rb', line 68 def info? !error.nil? end |
#to_sym ⇒ Symbol
Identify the state of the result.
82 83 84 85 86 87 88 89 90 |
# File 'lib/expresenter/pass.rb', line 82 def to_sym if success? :success elsif warning? :warning else :info end end |
#warning? ⇒ Boolean
The state of warning.
75 76 77 |
# File 'lib/expresenter/pass.rb', line 75 def warning? got.equal?(false) end |