expresenter 1.1.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +47 -59
- data/lib/expresenter.rb +3 -1
- data/lib/expresenter/common.rb +28 -48
- data/lib/expresenter/fail.rb +42 -23
- data/lib/expresenter/pass.rb +53 -23
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7681f55eec320e3a594a0dd3bf83bed059059c4fe0786c21702d100cdcff4686
|
4
|
+
data.tar.gz: 120bfa0781682b31af511528a1271118329745a0348e11a9508eb20daf55c082
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b9618acf9d062eacc9ac69ac3bca457fa6bbf7172baca826ee77f21365ef994e356fbf03b983fc39403a23fdecc7abdaa32ea4e5837a1260e5bf1696f8fb60c
|
7
|
+
data.tar.gz: 02a640a1f52ea92dce4e1fc8c88128142fb3ca9f2e14b811ba654008ce769f92c0d2137b88dd734a9bf91d8b68be758c0b6d862c3cf11d8b9aef4fc87bb02646
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# Expresenter
|
2
2
|
|
3
|
-
[](https://github.com/fixrb/expresenter/releases)
|
4
|
+
[](https://rubydoc.info/github/fixrb/expresenter/main)
|
5
|
+
[](https://github.com/fixrb/expresenter/actions?query=workflow%3Aci+branch%3Amain)
|
6
|
+
[](https://github.com/fixrb/expresenter/actions?query=workflow%3Arubocop+branch%3Amain)
|
7
|
+
[](https://github.com/fixrb/expresenter/raw/main/LICENSE.md)
|
8
8
|
|
9
9
|
> Expectation result presenter.
|
10
10
|
|
@@ -18,11 +18,15 @@ gem "expresenter"
|
|
18
18
|
|
19
19
|
And then execute:
|
20
20
|
|
21
|
-
|
21
|
+
```sh
|
22
|
+
bundle
|
23
|
+
```
|
22
24
|
|
23
25
|
Or install it yourself as:
|
24
26
|
|
25
|
-
|
27
|
+
```sh
|
28
|
+
gem install expresenter
|
29
|
+
```
|
26
30
|
|
27
31
|
## Usage
|
28
32
|
|
@@ -59,12 +63,11 @@ Failed expectations can be classified as:
|
|
59
63
|
The following parameters are required to instantiate the result:
|
60
64
|
|
61
65
|
* `actual`: Returned value by the challenged subject.
|
66
|
+
* `definition`: A readable string of the matcher and any expected values.
|
62
67
|
* `error`: Any possible raised exception.
|
63
68
|
* `expected`: The expected value.
|
64
69
|
* `got`: The result of the boolean comparison between the actual value and the expected value through the matcher.
|
65
70
|
* `negate`: Evaluated to a negative assertion?
|
66
|
-
* `valid`: Report if the test was `true` or `false`.
|
67
|
-
* `matcher`: The symbol representing a matcher.
|
68
71
|
* `level`: The requirement level (`:MUST`, `:SHOULD` or `:MAY`).
|
69
72
|
|
70
73
|
#### Examples
|
@@ -72,7 +75,7 @@ The following parameters are required to instantiate the result:
|
|
72
75
|
A passed expectation:
|
73
76
|
|
74
77
|
```ruby
|
75
|
-
result = Expresenter.call(true).new(actual: "FOO", error: nil, expected: "foo", got: true, negate: true,
|
78
|
+
result = Expresenter.call(true).new(actual: "FOO", definition: 'eq "foo"', error: nil, expected: "foo", got: true, negate: true, level: :MUST)
|
76
79
|
|
77
80
|
result.failed? # => false
|
78
81
|
result.failure? # => false
|
@@ -85,44 +88,40 @@ result.passed? # => true
|
|
85
88
|
result.negate? # => true
|
86
89
|
result.error? # => false
|
87
90
|
result.success? # => true
|
88
|
-
result.
|
89
|
-
result.
|
90
|
-
result.
|
91
|
-
result.maybe_negate # => " not"
|
92
|
-
result.summary # => "expected \"FOO\" not to eql \"foo\""
|
91
|
+
result.inspect # => "Expresenter::Pass(actual: \"FOO\", definition: \"eq \\\"foo\\\"\", error: nil, expected: \"foo\", got: true, negate: true, level: :MUST)"
|
92
|
+
result.definition # => "eq \"foo\""
|
93
|
+
result.summary # => "expected \"FOO\" not to eq \"foo\""
|
93
94
|
result.colored_char # => "\e[32m.\e[0m"
|
94
|
-
result.colored_string # => "\e[
|
95
|
-
result.message # => "Success: expected \"FOO\" not to
|
96
|
-
result.to_s # => "Success: expected \"FOO\" not to
|
95
|
+
result.colored_string # => "\e[32m\e[1mSuccess\e[22m: expected \"FOO\" not to eq \"foo\".\e[0m"
|
96
|
+
result.message # => "Success: expected \"FOO\" not to eq \"foo\"."
|
97
|
+
result.to_s # => "Success: expected \"FOO\" not to eq \"foo\"."
|
97
98
|
result.titre # => "Success"
|
98
99
|
```
|
99
100
|
|
100
101
|
A failed expectation:
|
101
102
|
|
102
103
|
```ruby
|
103
|
-
result = Expresenter.call(false).new(actual: "foo", error: Exception.new("BOOM"), expected: 42, got: true, negate: true,
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
actual.to_s # => "Exception: BOOM."
|
125
|
-
actual.titre # => "Exception"
|
104
|
+
result = Expresenter.call(false).new(actual: "foo", definition: "eq 42", error: Exception.new("BOOM"), expected: 42, got: true, negate: true, level: :MUST)
|
105
|
+
|
106
|
+
result.failed? # => true
|
107
|
+
result.failure? # => false
|
108
|
+
result.info? # => false
|
109
|
+
result.warning? # => false
|
110
|
+
result.to_sym # => :error
|
111
|
+
result.char # => "E"
|
112
|
+
result.emoji # => "💥"
|
113
|
+
result.passed? # => false
|
114
|
+
result.negate? # => true
|
115
|
+
result.error? # => true
|
116
|
+
result.success? # => true
|
117
|
+
result.inspect # => "Expresenter::Fail(actual: \"foo\", definition: \"eq 42\", error: #<Exception: BOOM>, expected: 42, got: true, negate: true, level: :MUST)"
|
118
|
+
result.definition # => "eq 42"
|
119
|
+
result.summary # => "BOOM"
|
120
|
+
result.colored_char # => "\e[31mE\e[0m"
|
121
|
+
result.colored_string # => "\e[31m\e[1mException\e[22m: BOOM.\e[0m"
|
122
|
+
result.message # => "Exception: BOOM."
|
123
|
+
result.to_s # => "Exception: BOOM."
|
124
|
+
result.titre # => "Exception"
|
126
125
|
```
|
127
126
|
|
128
127
|
### Return or Raise
|
@@ -132,19 +131,20 @@ To return the results which pass, and to raise the results which fail, the `with
|
|
132
131
|
In this example, the result passes, the instance is therefore returned:
|
133
132
|
|
134
133
|
```ruby
|
135
|
-
Expresenter.call(true).with(actual: "FOO", error: nil, expected: "foo", got: true, negate: true,
|
134
|
+
Expresenter.call(true).with(actual: "FOO", definition: 'eq "foo"', error: nil, expected: "foo", got: true, negate: true, level: :MUST) # => Expresenter::Pass(actual: "FOO", definition: "eq \"foo\"", error: nil, expected: "foo", got: true, negate: true, level: :MUST)
|
136
135
|
```
|
137
136
|
|
138
137
|
In this example, the result fails, so the exception is raised:
|
139
138
|
|
140
139
|
```ruby
|
141
|
-
Expresenter.call(false).with(actual: "foo", error: Exception.new("BOOM"), expected: 42, got: true, negate: true,
|
140
|
+
Expresenter.call(false).with(actual: "foo", definition: "eq 40", error: Exception.new("BOOM"), expected: 42, got: true, negate: true, level: :MUST)
|
142
141
|
```
|
143
142
|
|
144
143
|
> Traceback (most recent call last):
|
145
|
-
>
|
146
|
-
>
|
147
|
-
>
|
144
|
+
> 4: from ./bin/console:7:in `<main>'
|
145
|
+
> 3: from (irb):42
|
146
|
+
> 2: from (irb):43:in `rescue in irb_binding'
|
147
|
+
> 1: from /Users/cyril/github/fixrb/expresenter/lib/expresenter/fail.rb:25:in `with'
|
148
148
|
> Expresenter::Fail (Exception: BOOM.)
|
149
149
|
|
150
150
|
### More Examples
|
@@ -157,19 +157,13 @@ A full list of unit tests can be viewed (and executed) here:
|
|
157
157
|
* Home page: https://github.com/fixrb/expresenter
|
158
158
|
* Bugs/issues: https://github.com/fixrb/expresenter/issues
|
159
159
|
|
160
|
-
## Rubies
|
161
|
-
|
162
|
-
* [MRI](https://www.ruby-lang.org/)
|
163
|
-
* [Rubinius](https://rubinius.com/)
|
164
|
-
* [JRuby](https://www.jruby.org/)
|
165
|
-
|
166
160
|
## Versioning
|
167
161
|
|
168
162
|
__Expresenter__ follows [Semantic Versioning 2.0](https://semver.org/).
|
169
163
|
|
170
164
|
## License
|
171
165
|
|
172
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
166
|
+
The [gem](https://rubygems.org/gems/expresenter) is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
173
167
|
|
174
168
|
***
|
175
169
|
|
@@ -179,9 +173,3 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
179
173
|
src="https://github.com/fixrb/expresenter/raw/main/img/sashite.png"
|
180
174
|
alt="Sashite" /></a>
|
181
175
|
</p>
|
182
|
-
|
183
|
-
[gem]: https://rubygems.org/gems/expresenter
|
184
|
-
[travis]: https://travis-ci.org/fixrb/expresenter
|
185
|
-
[codeclimate]: https://codeclimate.com/github/fixrb/expresenter
|
186
|
-
[inchpages]: https://inch-ci.org/github/fixrb/expresenter
|
187
|
-
[rubydoc]: https://rubydoc.info/gems/expresenter/frames
|
data/lib/expresenter.rb
CHANGED
@@ -3,10 +3,12 @@
|
|
3
3
|
# Namespace for the Expresenter library.
|
4
4
|
#
|
5
5
|
# @example A passed expectation result presenter.
|
6
|
-
# Expresenter.call(true).with(actual: "FOO", error: nil, expected: "foo", got: true, negate: true,
|
6
|
+
# Expresenter.call(true).with(actual: "FOO", definition: 'eql "foo"', error: nil, expected: "foo", got: true, negate: true, level: :MUST) # => Expresenter::Pass(actual: "FOO", definition: "eql \"foo\"", error: nil, expected: "foo", got: true, negate: true, level: :MUST)
|
7
7
|
module Expresenter
|
8
8
|
# @param is_passed [Boolean] The value of an assertion.
|
9
|
+
#
|
9
10
|
# @return [Class<Pass>, Class<Fail>] The class of the result.
|
11
|
+
#
|
10
12
|
# @example Get the pass class result.
|
11
13
|
# call(true) # => Pass
|
12
14
|
def self.call(is_passed)
|
data/lib/expresenter/common.rb
CHANGED
@@ -3,9 +3,15 @@
|
|
3
3
|
module Expresenter
|
4
4
|
# Common collection of methods.
|
5
5
|
module Common
|
6
|
+
# White space.
|
7
|
+
SPACE = " "
|
8
|
+
|
6
9
|
# @return [#object_id] Returned value by the challenged subject.
|
7
10
|
attr_reader :actual
|
8
11
|
|
12
|
+
# @return [String] A readable string of the matcher and any expected values.
|
13
|
+
attr_reader :definition
|
14
|
+
|
9
15
|
# @return [Exception, nil] Any possible raised exception.
|
10
16
|
attr_reader :error
|
11
17
|
|
@@ -16,9 +22,6 @@ module Expresenter
|
|
16
22
|
# actual value and the expected value through the matcher.
|
17
23
|
attr_reader :got
|
18
24
|
|
19
|
-
# @return [#object_id] The matcher.
|
20
|
-
attr_reader :matcher
|
21
|
-
|
22
25
|
# @return [:MUST, :SHOULD, :MAY] The requirement level of the expectation.
|
23
26
|
attr_reader :level
|
24
27
|
|
@@ -50,40 +53,17 @@ module Expresenter
|
|
50
53
|
got.equal?(true)
|
51
54
|
end
|
52
55
|
|
53
|
-
# The value of the boolean comparison between the actual value and the
|
54
|
-
# expected value.
|
55
|
-
#
|
56
|
-
# @return [Boolean] The test was true or false?
|
57
|
-
def valid?
|
58
|
-
@valid
|
59
|
-
end
|
60
|
-
|
61
56
|
# A string containing a human-readable representation of the result.
|
62
57
|
#
|
63
58
|
# @return [String] The human-readable representation of the result.
|
64
59
|
def inspect
|
65
|
-
"#{self.class}(actual: #{actual.inspect}, "
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
"valid: #{valid?.inspect})" \
|
73
|
-
end
|
74
|
-
|
75
|
-
# The readable definition.
|
76
|
-
#
|
77
|
-
# @return [String] A readable string of the definition.
|
78
|
-
def definition
|
79
|
-
[matcher, expected&.inspect].compact.join(" ")
|
80
|
-
end
|
81
|
-
|
82
|
-
# The negation, if any.
|
83
|
-
#
|
84
|
-
# @return [String] The negation, or an empty string.
|
85
|
-
def maybe_negate
|
86
|
-
negate? ? " not" : ""
|
60
|
+
"#{self.class}(actual: #{actual.inspect}, " \
|
61
|
+
"definition: #{definition.inspect}, " \
|
62
|
+
"error: #{error.inspect}, " \
|
63
|
+
"expected: #{expected.inspect}, " \
|
64
|
+
"got: #{got.inspect}, " \
|
65
|
+
"negate: #{negate?.inspect}, " \
|
66
|
+
"level: #{level.inspect})"
|
87
67
|
end
|
88
68
|
|
89
69
|
# The summary of the result.
|
@@ -95,9 +75,9 @@ module Expresenter
|
|
95
75
|
elsif actual.is_a?(::Exception)
|
96
76
|
actual.message
|
97
77
|
elsif actual == expected
|
98
|
-
"expected
|
78
|
+
["expected", negation, "to", definition].compact.join(SPACE)
|
99
79
|
else
|
100
|
-
"expected
|
80
|
+
["expected", actual.inspect, negation, "to", definition].compact.join(SPACE)
|
101
81
|
end
|
102
82
|
end
|
103
83
|
|
@@ -112,7 +92,7 @@ module Expresenter
|
|
112
92
|
#
|
113
93
|
# @return [String] A string representing the result.
|
114
94
|
def colored_string
|
115
|
-
color(
|
95
|
+
color(to_bold_s)
|
116
96
|
end
|
117
97
|
|
118
98
|
# The representation of the result.
|
@@ -135,18 +115,18 @@ module Expresenter
|
|
135
115
|
|
136
116
|
protected
|
137
117
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
118
|
+
# The negation, if any.
|
119
|
+
#
|
120
|
+
# @return [String, nil] The negation, or an empty string.
|
121
|
+
def negation
|
122
|
+
"not" if negate?
|
123
|
+
end
|
124
|
+
|
125
|
+
# The representation of the result with the title in bold.
|
126
|
+
#
|
127
|
+
# @return [String] A string representing the result with the title in bold.
|
128
|
+
def to_bold_s
|
129
|
+
"\e[1m#{titre}\e[22m: #{summary}."
|
150
130
|
end
|
151
131
|
end
|
152
132
|
end
|
data/lib/expresenter/fail.rb
CHANGED
@@ -5,6 +5,18 @@ require_relative "common"
|
|
5
5
|
module Expresenter
|
6
6
|
# The class that is responsible for reporting that an expectation is false.
|
7
7
|
class Fail < ::StandardError
|
8
|
+
# Char representing a failure.
|
9
|
+
FAILURE_CHAR = "F"
|
10
|
+
|
11
|
+
# Emoji representing a failure.
|
12
|
+
FAILURE_EMOJI = "❌"
|
13
|
+
|
14
|
+
# Char representing an error.
|
15
|
+
ERROR_CHAR = "E"
|
16
|
+
|
17
|
+
# Emoji representing an error.
|
18
|
+
ERROR_EMOJI = "💥"
|
19
|
+
|
8
20
|
include Common
|
9
21
|
|
10
22
|
# @param (see Fail#initialize)
|
@@ -15,26 +27,23 @@ module Expresenter
|
|
15
27
|
|
16
28
|
# Initialize method.
|
17
29
|
#
|
18
|
-
# @param actual
|
19
|
-
# @param
|
20
|
-
#
|
21
|
-
# @param
|
30
|
+
# @param actual [#object_id] Returned value by the challenged subject.
|
31
|
+
# @param definition [String] A readable string of the matcher and any
|
32
|
+
# expected values.
|
33
|
+
# @param error [Exception, nil] Any possible raised exception.
|
34
|
+
# @param expected [#object_id] The expected value.
|
35
|
+
# @param got [Boolean, nil] The result of the boolean comparison
|
22
36
|
# between the actual value and the expected value through the matcher.
|
23
|
-
# @param negate
|
24
|
-
# @param
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
@
|
31
|
-
@
|
32
|
-
@
|
33
|
-
@got = got
|
34
|
-
@negate = negate
|
35
|
-
@valid = valid
|
36
|
-
@matcher = matcher
|
37
|
-
@level = level
|
37
|
+
# @param negate [Boolean] Evaluated to a negative assertion?
|
38
|
+
# @param level [:MUST, :SHOULD, :MAY] The requirement level.
|
39
|
+
def initialize(actual:, definition:, error:, expected:, got:, negate:, level:)
|
40
|
+
@actual = actual
|
41
|
+
@definition = definition
|
42
|
+
@error = error
|
43
|
+
@expected = expected
|
44
|
+
@got = got
|
45
|
+
@negate = negate
|
46
|
+
@level = level
|
38
47
|
|
39
48
|
super(to_s)
|
40
49
|
end
|
@@ -83,9 +92,9 @@ module Expresenter
|
|
83
92
|
# @return [String] The char that identify the result.
|
84
93
|
def char
|
85
94
|
if failure?
|
86
|
-
|
95
|
+
FAILURE_CHAR
|
87
96
|
else
|
88
|
-
|
97
|
+
ERROR_CHAR
|
89
98
|
end
|
90
99
|
end
|
91
100
|
|
@@ -94,9 +103,19 @@ module Expresenter
|
|
94
103
|
# @return [String] The emoji that identify the result.
|
95
104
|
def emoji
|
96
105
|
if failure?
|
97
|
-
|
106
|
+
FAILURE_EMOJI
|
107
|
+
else
|
108
|
+
ERROR_EMOJI
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
protected
|
113
|
+
|
114
|
+
def color(str)
|
115
|
+
if failure?
|
116
|
+
"\e[35m#{str}\e[0m" # purple
|
98
117
|
else
|
99
|
-
"
|
118
|
+
"\e[31m#{str}\e[0m" # red
|
100
119
|
end
|
101
120
|
end
|
102
121
|
end
|
data/lib/expresenter/pass.rb
CHANGED
@@ -5,6 +5,24 @@ require_relative "common"
|
|
5
5
|
module Expresenter
|
6
6
|
# The class that is responsible for reporting that an expectation is true.
|
7
7
|
class Pass
|
8
|
+
# Char representing an info.
|
9
|
+
INFO_CHAR = "I"
|
10
|
+
|
11
|
+
# Emoji representing an info.
|
12
|
+
INFO_EMOJI = "💡"
|
13
|
+
|
14
|
+
# Char representing a success.
|
15
|
+
SUCCESS_CHAR = "."
|
16
|
+
|
17
|
+
# Emoji representing a success.
|
18
|
+
SUCCESS_EMOJI = "✅"
|
19
|
+
|
20
|
+
# Char representing a warning.
|
21
|
+
WARNING_CHAR = "W"
|
22
|
+
|
23
|
+
# Emoji representing a warning.
|
24
|
+
WARNING_EMOJI = "⚠️"
|
25
|
+
|
8
26
|
include Common
|
9
27
|
|
10
28
|
# @param (see Pass#initialize)
|
@@ -18,25 +36,22 @@ module Expresenter
|
|
18
36
|
# Initialize method.
|
19
37
|
#
|
20
38
|
# @param actual [#object_id] Returned value by the challenged subject.
|
39
|
+
# @param definition [String] A readable string of the matcher and any
|
40
|
+
# expected values.
|
21
41
|
# @param error [Exception, nil] Any possible raised exception.
|
22
42
|
# @param expected [#object_id] The expected value.
|
23
43
|
# @param got [Boolean, nil] The result of the boolean comparison
|
24
44
|
# between the actual value and the expected value through the matcher.
|
25
45
|
# @param negate [Boolean] Evaluated to a negative assertion?
|
26
|
-
# @param valid [Boolean] Report if the test was true or false?
|
27
|
-
# @param matcher [Symbol] The matcher.
|
28
46
|
# @param level [:MUST, :SHOULD, :MAY] The requirement level.
|
29
|
-
def initialize(actual:, error:, expected:, got:, negate:,
|
30
|
-
|
31
|
-
|
32
|
-
@
|
33
|
-
@
|
34
|
-
@
|
35
|
-
@
|
36
|
-
@
|
37
|
-
@valid = valid
|
38
|
-
@matcher = matcher
|
39
|
-
@level = level
|
47
|
+
def initialize(actual:, definition:, error:, expected:, got:, negate:, level:)
|
48
|
+
@actual = actual
|
49
|
+
@definition = definition
|
50
|
+
@error = error
|
51
|
+
@expected = expected
|
52
|
+
@got = got
|
53
|
+
@negate = negate
|
54
|
+
@level = level
|
40
55
|
end
|
41
56
|
|
42
57
|
# Did the test fail?
|
@@ -71,10 +86,13 @@ module Expresenter
|
|
71
86
|
#
|
72
87
|
# @return [Symbol] The identifier of the state.
|
73
88
|
def to_sym
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
89
|
+
if success?
|
90
|
+
:success
|
91
|
+
elsif warning?
|
92
|
+
:warning
|
93
|
+
else
|
94
|
+
:info
|
95
|
+
end
|
78
96
|
end
|
79
97
|
|
80
98
|
# Express the result with one char.
|
@@ -82,11 +100,11 @@ module Expresenter
|
|
82
100
|
# @return [String] The char that identify the result.
|
83
101
|
def char
|
84
102
|
if success?
|
85
|
-
|
103
|
+
SUCCESS_CHAR
|
86
104
|
elsif warning?
|
87
|
-
|
105
|
+
WARNING_CHAR
|
88
106
|
else
|
89
|
-
|
107
|
+
INFO_CHAR
|
90
108
|
end
|
91
109
|
end
|
92
110
|
|
@@ -95,11 +113,23 @@ module Expresenter
|
|
95
113
|
# @return [String] The emoji that identify the result.
|
96
114
|
def emoji
|
97
115
|
if success?
|
98
|
-
|
116
|
+
SUCCESS_EMOJI
|
117
|
+
elsif warning?
|
118
|
+
WARNING_EMOJI
|
119
|
+
else
|
120
|
+
INFO_EMOJI
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
protected
|
125
|
+
|
126
|
+
def color(str)
|
127
|
+
if success?
|
128
|
+
"\e[32m#{str}\e[0m" # green
|
99
129
|
elsif warning?
|
100
|
-
"
|
130
|
+
"\e[33m#{str}\e[0m" # yellow
|
101
131
|
else
|
102
|
-
"
|
132
|
+
"\e[36m#{str}\e[0m" # blue
|
103
133
|
end
|
104
134
|
end
|
105
135
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: expresenter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Kato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: brutal
|
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
167
|
- !ruby/object:Gem::Version
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
|
-
rubygems_version: 3.1.
|
170
|
+
rubygems_version: 3.1.6
|
171
171
|
signing_key:
|
172
172
|
specification_version: 4
|
173
173
|
summary: Expectation result presenter.
|