expresenter 1.2.1 → 1.3.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 +6 -9
- data/lib/expresenter.rb +3 -1
- data/lib/expresenter/common.rb +2 -10
- data/lib/expresenter/fail.rb +7 -5
- data/lib/expresenter/pass.rb +10 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b293c0c6ffd15b336c00fcc841647e6d244623346dd86ab6cf319c05cfc7d909
|
4
|
+
data.tar.gz: 3901ec01f1277302150665002b97c157ba26846bf08e344bd364fbb7fdec874d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db88b4f5c706ae1aaf48fdf6b2b45aa0ab4d0fe1f5a557331e51b8b9c9333f07305ec1f6d5f3287a34ed39e20396fd2d4879f5b186e94e9653420604a1d2ca3d
|
7
|
+
data.tar.gz: 04c1db7b8ea904a67397305f111bde2e4dadac40c6cdd392cb855b3b4db24a8ae904c92cfe07332cdc137cceea57481d9d920803941722b3e8749db16d0b346b
|
data/README.md
CHANGED
@@ -66,7 +66,6 @@ The following parameters are required to instantiate the result:
|
|
66
66
|
* `expected`: The expected value.
|
67
67
|
* `got`: The result of the boolean comparison between the actual value and the expected value through the matcher.
|
68
68
|
* `negate`: Evaluated to a negative assertion?
|
69
|
-
* `valid`: Report if the test was `true` or `false`.
|
70
69
|
* `matcher`: The symbol representing a matcher.
|
71
70
|
* `level`: The requirement level (`:MUST`, `:SHOULD` or `:MAY`).
|
72
71
|
|
@@ -75,7 +74,7 @@ The following parameters are required to instantiate the result:
|
|
75
74
|
A passed expectation:
|
76
75
|
|
77
76
|
```ruby
|
78
|
-
result = Expresenter.call(true).new(actual: "FOO", error: nil, expected: "foo", got: true, negate: true,
|
77
|
+
result = Expresenter.call(true).new(actual: "FOO", error: nil, expected: "foo", got: true, negate: true, matcher: :eql, level: :MUST)
|
79
78
|
|
80
79
|
result.failed? # => false
|
81
80
|
result.failure? # => false
|
@@ -88,8 +87,7 @@ result.passed? # => true
|
|
88
87
|
result.negate? # => true
|
89
88
|
result.error? # => false
|
90
89
|
result.success? # => true
|
91
|
-
result.
|
92
|
-
result.inspect # => "Expresenter::Pass(actual: \"FOO\", error: nil, expected: \"foo\", got: true, matcher: :eql, negate: true, level: :MUST, valid: true)"
|
90
|
+
result.inspect # => "Expresenter::Pass(actual: \"FOO\", error: nil, expected: \"foo\", got: true, matcher: :eql, negate: true, level: :MUST)"
|
93
91
|
result.definition # => "eql \"foo\""
|
94
92
|
result.summary # => "expected \"FOO\" not to eql \"foo\""
|
95
93
|
result.colored_char # => "\e[32m.\e[0m"
|
@@ -102,7 +100,7 @@ result.titre # => "Success"
|
|
102
100
|
A failed expectation:
|
103
101
|
|
104
102
|
```ruby
|
105
|
-
result = Expresenter.call(false).new(actual: "foo", error: Exception.new("BOOM"), expected: 42, got: true, negate: true,
|
103
|
+
result = Expresenter.call(false).new(actual: "foo", error: Exception.new("BOOM"), expected: 42, got: true, negate: true, matcher: :eql, level: :MUST)
|
106
104
|
|
107
105
|
result.failed? # => true
|
108
106
|
result.failure? # => false
|
@@ -115,8 +113,7 @@ result.passed? # => false
|
|
115
113
|
result.negate? # => true
|
116
114
|
result.error? # => true
|
117
115
|
result.success? # => true
|
118
|
-
result.
|
119
|
-
result.inspect # => "Expresenter::Fail(actual: \"foo\", error: #<Exception: BOOM>, expected: 42, got: true, matcher: :eql, negate: true, level: :MUST, valid: true)"
|
116
|
+
result.inspect # => "Expresenter::Fail(actual: \"foo\", error: #<Exception: BOOM>, expected: 42, got: true, matcher: :eql, negate: true, level: :MUST)"
|
120
117
|
result.definition # => "eql 42"
|
121
118
|
result.summary # => "BOOM"
|
122
119
|
result.colored_char # => "\e[31mE\e[0m"
|
@@ -133,13 +130,13 @@ To return the results which pass, and to raise the results which fail, the `with
|
|
133
130
|
In this example, the result passes, the instance is therefore returned:
|
134
131
|
|
135
132
|
```ruby
|
136
|
-
Expresenter.call(true).with(actual: "FOO", error: nil, expected: "foo", got: true, negate: true,
|
133
|
+
Expresenter.call(true).with(actual: "FOO", error: nil, expected: "foo", got: true, negate: true, matcher: :eql, level: :MUST) # => Expresenter::Pass(actual: "FOO", error: nil, expected: "foo", got: true, matcher: :eql, negate: true, level: :MUST)
|
137
134
|
```
|
138
135
|
|
139
136
|
In this example, the result fails, so the exception is raised:
|
140
137
|
|
141
138
|
```ruby
|
142
|
-
Expresenter.call(false).with(actual: "foo", error: Exception.new("BOOM"), expected: 42, got: true, negate: true,
|
139
|
+
Expresenter.call(false).with(actual: "foo", error: Exception.new("BOOM"), expected: 42, got: true, negate: true, matcher: :eql, level: :MUST)
|
143
140
|
```
|
144
141
|
|
145
142
|
> Traceback (most recent call last):
|
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", error: nil, expected: "foo", got: true, negate: true, matcher: :eql, level: :MUST) # => Expresenter::Pass(actual: "FOO", error: nil, expected: "foo", got: true, matcher: :eql, 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,6 +3,7 @@
|
|
3
3
|
module Expresenter
|
4
4
|
# Common collection of methods.
|
5
5
|
module Common
|
6
|
+
# White space.
|
6
7
|
SPACE = " "
|
7
8
|
|
8
9
|
# @return [#object_id] Returned value by the challenged subject.
|
@@ -52,14 +53,6 @@ module Expresenter
|
|
52
53
|
got.equal?(true)
|
53
54
|
end
|
54
55
|
|
55
|
-
# The value of the boolean comparison between the actual value and the
|
56
|
-
# expected value.
|
57
|
-
#
|
58
|
-
# @return [Boolean] The test was true or false?
|
59
|
-
def valid?
|
60
|
-
@valid
|
61
|
-
end
|
62
|
-
|
63
56
|
# A string containing a human-readable representation of the result.
|
64
57
|
#
|
65
58
|
# @return [String] The human-readable representation of the result.
|
@@ -70,8 +63,7 @@ module Expresenter
|
|
70
63
|
"got: #{got.inspect}, " \
|
71
64
|
"matcher: #{matcher.inspect}, " \
|
72
65
|
"negate: #{negate?.inspect}, " \
|
73
|
-
"level: #{level.inspect}
|
74
|
-
"valid: #{valid?.inspect})" \
|
66
|
+
"level: #{level.inspect}" \
|
75
67
|
end
|
76
68
|
|
77
69
|
# The readable definition.
|
data/lib/expresenter/fail.rb
CHANGED
@@ -5,10 +5,16 @@ 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.
|
8
9
|
FAILURE_CHAR = "F"
|
10
|
+
|
11
|
+
# Emoji representing a failure.
|
9
12
|
FAILURE_EMOJI = "❌"
|
10
13
|
|
14
|
+
# Char representing an error.
|
11
15
|
ERROR_CHAR = "E"
|
16
|
+
|
17
|
+
# Emoji representing an error.
|
12
18
|
ERROR_EMOJI = "💥"
|
13
19
|
|
14
20
|
include Common
|
@@ -27,18 +33,14 @@ module Expresenter
|
|
27
33
|
# @param got [Boolean, nil] The result of the boolean comparison
|
28
34
|
# between the actual value and the expected value through the matcher.
|
29
35
|
# @param negate [Boolean] Evaluated to a negative assertion?
|
30
|
-
# @param valid [Boolean] Report if the test was true or false?
|
31
36
|
# @param matcher [Symbol] The matcher.
|
32
37
|
# @param level [:MUST, :SHOULD, :MAY] The requirement level.
|
33
|
-
def initialize(actual:, error:, expected:, got:, negate:,
|
34
|
-
matcher:, level:)
|
35
|
-
|
38
|
+
def initialize(actual:, error:, expected:, got:, negate:, matcher:, level:)
|
36
39
|
@actual = actual
|
37
40
|
@error = error
|
38
41
|
@expected = expected
|
39
42
|
@got = got
|
40
43
|
@negate = negate
|
41
|
-
@valid = valid
|
42
44
|
@matcher = matcher
|
43
45
|
@level = level
|
44
46
|
|
data/lib/expresenter/pass.rb
CHANGED
@@ -5,13 +5,22 @@ 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.
|
8
9
|
INFO_CHAR = "I"
|
10
|
+
|
11
|
+
# Emoji representing an info.
|
9
12
|
INFO_EMOJI = "💡"
|
10
13
|
|
14
|
+
# Char representing a success.
|
11
15
|
SUCCESS_CHAR = "."
|
16
|
+
|
17
|
+
# Emoji representing a success.
|
12
18
|
SUCCESS_EMOJI = "✅"
|
13
19
|
|
20
|
+
# Char representing a warning.
|
14
21
|
WARNING_CHAR = "W"
|
22
|
+
|
23
|
+
# Emoji representing a warning.
|
15
24
|
WARNING_EMOJI = "⚠️"
|
16
25
|
|
17
26
|
include Common
|
@@ -32,18 +41,14 @@ module Expresenter
|
|
32
41
|
# @param got [Boolean, nil] The result of the boolean comparison
|
33
42
|
# between the actual value and the expected value through the matcher.
|
34
43
|
# @param negate [Boolean] Evaluated to a negative assertion?
|
35
|
-
# @param valid [Boolean] Report if the test was true or false?
|
36
44
|
# @param matcher [Symbol] The matcher.
|
37
45
|
# @param level [:MUST, :SHOULD, :MAY] The requirement level.
|
38
|
-
def initialize(actual:, error:, expected:, got:, negate:,
|
39
|
-
matcher:, level:)
|
40
|
-
|
46
|
+
def initialize(actual:, error:, expected:, got:, negate:, matcher:, level:)
|
41
47
|
@actual = actual
|
42
48
|
@error = error
|
43
49
|
@expected = expected
|
44
50
|
@got = got
|
45
51
|
@negate = negate
|
46
|
-
@valid = valid
|
47
52
|
@matcher = matcher
|
48
53
|
@level = level
|
49
54
|
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.3.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-06-
|
11
|
+
date: 2021-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: brutal
|