expresenter 1.4.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -15
- data/lib/expresenter/common.rb +0 -18
- data/lib/expresenter/fail.rb +1 -3
- data/lib/expresenter/pass.rb +1 -3
- data/lib/expresenter.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ddc8ef213f1b42ee370c0e8332886cc0c0a158197bda6eaba301f0a0edeae6f
|
4
|
+
data.tar.gz: bee453e0190c6ce4e6a03955ad586af392ad424d2338196618ddcc608137d7ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3589fcd607346650908c5c95f19eafe8a30813ccc869f2dde6c155112b3a9bbd64053d872f2de2c32eecc7ac520348043d9dd103bb9149c948dd76a5ad7856eb
|
7
|
+
data.tar.gz: bbb3b0eaa9173024a9df1d6806bb243597fcfa1b7d7e7c96e68e70f5532bfa92eaf44d8b58b4cde56810ac6fed993775805677e52f17df474790de5f138b9600
|
data/README.md
CHANGED
@@ -6,7 +6,16 @@
|
|
6
6
|
[![RuboCop](https://github.com/fixrb/expresenter/workflows/RuboCop/badge.svg?branch=main)](https://github.com/fixrb/expresenter/actions?query=workflow%3Arubocop+branch%3Amain)
|
7
7
|
[![License](https://img.shields.io/github/license/fixrb/expresenter?label=License&logo=github)](https://github.com/fixrb/expresenter/raw/main/LICENSE.md)
|
8
8
|
|
9
|
-
>
|
9
|
+
> A Ruby gem for presenting test expectation results with rich formatting and requirement level support. Perfect for test frameworks and assertion libraries that need flexible result reporting with support for MUST/SHOULD/MAY requirement levels.
|
10
|
+
|
11
|
+
## Features
|
12
|
+
|
13
|
+
- Rich result formatting with colored output
|
14
|
+
- Support for MUST/SHOULD/MAY requirement levels
|
15
|
+
- Multiple result classification: success, warning, info, failure, and error
|
16
|
+
- Emoji support for visual result indication (✅, ⚠️, 💡, ❌, 💥)
|
17
|
+
- Flexible negation support for negative assertions
|
18
|
+
- Detailed error reporting with custom messages
|
10
19
|
|
11
20
|
## Installation
|
12
21
|
|
@@ -65,7 +74,6 @@ The following parameters are required to instantiate the result:
|
|
65
74
|
* `actual`: Returned value by the challenged subject.
|
66
75
|
* `definition`: A readable string of the matcher and any expected values.
|
67
76
|
* `error`: Any possible raised exception.
|
68
|
-
* `expected`: The expected value.
|
69
77
|
* `got`: The result of the boolean comparison between the actual value and the expected value through the matcher.
|
70
78
|
* `negate`: Evaluated to a negative assertion?
|
71
79
|
* `level`: The requirement level (`:MUST`, `:SHOULD` or `:MAY`).
|
@@ -75,7 +83,7 @@ The following parameters are required to instantiate the result:
|
|
75
83
|
A passed expectation:
|
76
84
|
|
77
85
|
```ruby
|
78
|
-
result = Expresenter.call(true).new(actual: "FOO", definition: 'eq "foo"', error: nil,
|
86
|
+
result = Expresenter.call(true).new(actual: "FOO", definition: 'eq "foo"', error: nil, got: true, negate: true, level: :MUST)
|
79
87
|
|
80
88
|
result.failed? # => false
|
81
89
|
result.failure? # => false
|
@@ -88,7 +96,6 @@ result.passed? # => true
|
|
88
96
|
result.negate? # => true
|
89
97
|
result.error? # => false
|
90
98
|
result.success? # => true
|
91
|
-
result.inspect # => "Expresenter::Pass(actual: \"FOO\", definition: \"eq \\\"foo\\\"\", error: nil, expected: \"foo\", got: true, negate: true, level: :MUST)"
|
92
99
|
result.definition # => "eq \"foo\""
|
93
100
|
result.summary # => "expected \"FOO\" not to eq \"foo\""
|
94
101
|
result.colored_char # => "\e[32m.\e[0m"
|
@@ -101,7 +108,7 @@ result.titre # => "Success"
|
|
101
108
|
A failed expectation:
|
102
109
|
|
103
110
|
```ruby
|
104
|
-
result = Expresenter.call(false).new(actual: "foo", definition: "eq 42", error: Exception.new("BOOM"),
|
111
|
+
result = Expresenter.call(false).new(actual: "foo", definition: "eq 42", error: Exception.new("BOOM"), got: true, negate: true, level: :MUST)
|
105
112
|
|
106
113
|
result.failed? # => true
|
107
114
|
result.failure? # => false
|
@@ -114,7 +121,6 @@ result.passed? # => false
|
|
114
121
|
result.negate? # => true
|
115
122
|
result.error? # => true
|
116
123
|
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
124
|
result.definition # => "eq 42"
|
119
125
|
result.summary # => "BOOM"
|
120
126
|
result.colored_char # => "\e[31mE\e[0m"
|
@@ -131,13 +137,13 @@ To return the results which pass, and to raise the results which fail, the `with
|
|
131
137
|
In this example, the result passes, the instance is therefore returned:
|
132
138
|
|
133
139
|
```ruby
|
134
|
-
Expresenter.call(true).with(actual: "FOO", definition: 'eq "foo"', error: nil,
|
140
|
+
Expresenter.call(true).with(actual: "FOO", definition: 'eq "foo"', error: nil, got: true, negate: true, level: :MUST) # => Expresenter::Pass(actual: "FOO", definition: "eq \"foo\"", error: nil, got: true, negate: true, level: :MUST)
|
135
141
|
```
|
136
142
|
|
137
143
|
In this example, the result fails, so the exception is raised:
|
138
144
|
|
139
145
|
```ruby
|
140
|
-
Expresenter.call(false).with(actual: "foo", definition: "eq 40", error: Exception.new("BOOM"),
|
146
|
+
Expresenter.call(false).with(actual: "foo", definition: "eq 40", error: Exception.new("BOOM"), got: true, negate: true, level: :MUST)
|
141
147
|
```
|
142
148
|
|
143
149
|
> Traceback (most recent call last):
|
@@ -165,11 +171,6 @@ __Expresenter__ follows [Semantic Versioning 2.0](https://semver.org/).
|
|
165
171
|
|
166
172
|
The [gem](https://rubygems.org/gems/expresenter) is available as open source under the terms of the [MIT License](https://github.com/fixrb/expresenter/raw/main/LICENSE.md).
|
167
173
|
|
168
|
-
|
174
|
+
## Sponsors
|
169
175
|
|
170
|
-
|
171
|
-
This project is sponsored by:<br />
|
172
|
-
<a href="https://sashite.com/"><img
|
173
|
-
src="https://github.com/fixrb/expresenter/raw/main/img/sashite.png"
|
174
|
-
alt="Sashité" /></a>
|
175
|
-
</p>
|
176
|
+
This project is sponsored by [Sashité](https://sashite.com/)
|
data/lib/expresenter/common.rb
CHANGED
@@ -15,9 +15,6 @@ module Expresenter
|
|
15
15
|
# @return [Exception, nil] Any possible raised exception.
|
16
16
|
attr_reader :error
|
17
17
|
|
18
|
-
# @return [#object_id] The expected value.
|
19
|
-
attr_reader :expected
|
20
|
-
|
21
18
|
# @return [#object_id] The result of the boolean comparison between the
|
22
19
|
# actual value and the expected value through the matcher.
|
23
20
|
attr_reader :got
|
@@ -53,19 +50,6 @@ module Expresenter
|
|
53
50
|
got.equal?(true)
|
54
51
|
end
|
55
52
|
|
56
|
-
# A string containing a human-readable representation of the result.
|
57
|
-
#
|
58
|
-
# @return [String] The human-readable representation of the result.
|
59
|
-
def inspect
|
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})"
|
67
|
-
end
|
68
|
-
|
69
53
|
# The summary of the result.
|
70
54
|
#
|
71
55
|
# @return [String] A string representing the summary of the result.
|
@@ -74,8 +58,6 @@ module Expresenter
|
|
74
58
|
error.message
|
75
59
|
elsif actual.is_a?(::Exception)
|
76
60
|
actual.message
|
77
|
-
elsif actual == expected
|
78
|
-
["expected", negation, "to", definition].compact.join(SPACE)
|
79
61
|
else
|
80
62
|
["expected", actual.inspect, negation, "to", definition].compact.join(SPACE)
|
81
63
|
end
|
data/lib/expresenter/fail.rb
CHANGED
@@ -31,16 +31,14 @@ module Expresenter
|
|
31
31
|
# @param definition [String] A readable string of the matcher and any
|
32
32
|
# expected values.
|
33
33
|
# @param error [Exception, nil] Any possible raised exception.
|
34
|
-
# @param expected [#object_id] The expected value.
|
35
34
|
# @param got [Boolean, nil] The result of the boolean comparison
|
36
35
|
# between the actual value and the expected value through the matcher.
|
37
36
|
# @param negate [Boolean] Evaluated to a negative assertion?
|
38
37
|
# @param level [:MUST, :SHOULD, :MAY] The requirement level.
|
39
|
-
def initialize(actual:, definition:, error:,
|
38
|
+
def initialize(actual:, definition:, error:, got:, negate:, level:)
|
40
39
|
@actual = actual
|
41
40
|
@definition = definition
|
42
41
|
@error = error
|
43
|
-
@expected = expected
|
44
42
|
@got = got
|
45
43
|
@negate = negate
|
46
44
|
@level = level
|
data/lib/expresenter/pass.rb
CHANGED
@@ -39,16 +39,14 @@ module Expresenter
|
|
39
39
|
# @param definition [String] A readable string of the matcher and any
|
40
40
|
# expected values.
|
41
41
|
# @param error [Exception, nil] Any possible raised exception.
|
42
|
-
# @param expected [#object_id] The expected value.
|
43
42
|
# @param got [Boolean, nil] The result of the boolean comparison
|
44
43
|
# between the actual value and the expected value through the matcher.
|
45
44
|
# @param negate [Boolean] Evaluated to a negative assertion?
|
46
45
|
# @param level [:MUST, :SHOULD, :MAY] The requirement level.
|
47
|
-
def initialize(actual:, definition:, error:,
|
46
|
+
def initialize(actual:, definition:, error:, got:, negate:, level:)
|
48
47
|
@actual = actual
|
49
48
|
@definition = definition
|
50
49
|
@error = error
|
51
|
-
@expected = expected
|
52
50
|
@got = got
|
53
51
|
@negate = negate
|
54
52
|
@level = level
|
data/lib/expresenter.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Namespace for the Expresenter library.
|
4
4
|
#
|
5
5
|
# @example A passed expectation result presenter.
|
6
|
-
# Expresenter.call(true).with(actual: "FOO", definition: 'eql "foo"', error: nil,
|
6
|
+
# Expresenter.call(true).with(actual: "FOO", definition: 'eql "foo"', error: nil, got: true, negate: true, level: :MUST) # => Expresenter::Pass(actual: "FOO", definition: "eql \"foo\"", error: nil, got: true, negate: true, level: :MUST)
|
7
7
|
module Expresenter
|
8
8
|
# @param is_passed [Boolean] The value of an assertion.
|
9
9
|
#
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: expresenter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Kato
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date: 2024-
|
10
|
+
date: 2024-12-29 00:00:00.000000000 Z
|
12
11
|
dependencies: []
|
13
12
|
description: Expectation result presenter.
|
14
13
|
email: contact@cyril.email
|
@@ -27,7 +26,6 @@ licenses:
|
|
27
26
|
- MIT
|
28
27
|
metadata:
|
29
28
|
rubygems_mfa_required: 'true'
|
30
|
-
post_install_message:
|
31
29
|
rdoc_options: []
|
32
30
|
require_paths:
|
33
31
|
- lib
|
@@ -42,8 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
42
40
|
- !ruby/object:Gem::Version
|
43
41
|
version: '0'
|
44
42
|
requirements: []
|
45
|
-
rubygems_version: 3.
|
46
|
-
signing_key:
|
43
|
+
rubygems_version: 3.6.2
|
47
44
|
specification_version: 4
|
48
45
|
summary: Expectation result presenter.
|
49
46
|
test_files: []
|