expresenter 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7681f55eec320e3a594a0dd3bf83bed059059c4fe0786c21702d100cdcff4686
4
- data.tar.gz: 120bfa0781682b31af511528a1271118329745a0348e11a9508eb20daf55c082
3
+ metadata.gz: 0ddc8ef213f1b42ee370c0e8332886cc0c0a158197bda6eaba301f0a0edeae6f
4
+ data.tar.gz: bee453e0190c6ce4e6a03955ad586af392ad424d2338196618ddcc608137d7ab
5
5
  SHA512:
6
- metadata.gz: 9b9618acf9d062eacc9ac69ac3bca457fa6bbf7172baca826ee77f21365ef994e356fbf03b983fc39403a23fdecc7abdaa32ea4e5837a1260e5bf1696f8fb60c
7
- data.tar.gz: 02a640a1f52ea92dce4e1fc8c88128142fb3ca9f2e14b811ba654008ce769f92c0d2137b88dd734a9bf91d8b68be758c0b6d862c3cf11d8b9aef4fc87bb02646
6
+ metadata.gz: 3589fcd607346650908c5c95f19eafe8a30813ccc869f2dde6c155112b3a9bbd64053d872f2de2c32eecc7ac520348043d9dd103bb9149c948dd76a5ad7856eb
7
+ data.tar.gz: bbb3b0eaa9173024a9df1d6806bb243597fcfa1b7d7e7c96e68e70f5532bfa92eaf44d8b58b4cde56810ac6fed993775805677e52f17df474790de5f138b9600
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021 Cyril Kato
3
+ Copyright (c) 2021-2024 Cyril Kato
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,12 +1,21 @@
1
1
  # Expresenter
2
2
 
3
- [![Version](https://img.shields.io/github/v/tag/fixrb/expresenter?label=Version&logo=github)](https://github.com/fixrb/expresenter/releases)
3
+ [![Version](https://img.shields.io/github/v/tag/fixrb/expresenter?label=Version&logo=github)](https://github.com/fixrb/expresenter/tags)
4
4
  [![Yard documentation](https://img.shields.io/badge/Yard-documentation-blue.svg?logo=github)](https://rubydoc.info/github/fixrb/expresenter/main)
5
- [![CI](https://github.com/fixrb/expresenter/workflows/CI/badge.svg?branch=main)](https://github.com/fixrb/expresenter/actions?query=workflow%3Aci+branch%3Amain)
5
+ [![Ruby](https://github.com/fixrb/expresenter/workflows/Ruby/badge.svg?branch=main)](https://github.com/fixrb/expresenter/actions?query=workflow%3Aruby+branch%3Amain)
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
- > Expectation result presenter.
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
 
@@ -19,7 +28,7 @@ gem "expresenter"
19
28
  And then execute:
20
29
 
21
30
  ```sh
22
- bundle
31
+ bundle install
23
32
  ```
24
33
 
25
34
  Or install it yourself as:
@@ -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, expected: "foo", got: true, negate: true, level: :MUST)
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"), expected: 42, got: true, negate: true, level: :MUST)
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, 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)
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"), expected: 42, got: true, negate: true, level: :MUST)
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):
@@ -163,13 +169,8 @@ __Expresenter__ follows [Semantic Versioning 2.0](https://semver.org/).
163
169
 
164
170
  ## License
165
171
 
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).
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
- <p>
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="Sashite" /></a>
175
- </p>
176
+ This project is sponsored by [Sashité](https://sashite.com/)
@@ -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
@@ -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:, expected:, got:, negate:, level:)
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
@@ -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:, expected:, got:, negate:, level:)
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, 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)
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,141 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expresenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
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: 2021-07-23 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: brutal
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: rubocop-md
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: rubocop-performance
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: rubocop-rake
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: rubocop-thread_safety
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: simplecov
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: yard
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
10
+ date: 2024-12-29 00:00:00.000000000 Z
11
+ dependencies: []
139
12
  description: Expectation result presenter.
140
13
  email: contact@cyril.email
141
14
  executables: []
@@ -151,8 +24,8 @@ files:
151
24
  homepage: https://github.com/fixrb/expresenter
152
25
  licenses:
153
26
  - MIT
154
- metadata: {}
155
- post_install_message:
27
+ metadata:
28
+ rubygems_mfa_required: 'true'
156
29
  rdoc_options: []
157
30
  require_paths:
158
31
  - lib
@@ -160,15 +33,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
33
  requirements:
161
34
  - - ">="
162
35
  - !ruby/object:Gem::Version
163
- version: 2.7.0
36
+ version: 3.2.0
164
37
  required_rubygems_version: !ruby/object:Gem::Requirement
165
38
  requirements:
166
39
  - - ">="
167
40
  - !ruby/object:Gem::Version
168
41
  version: '0'
169
42
  requirements: []
170
- rubygems_version: 3.1.6
171
- signing_key:
43
+ rubygems_version: 3.6.2
172
44
  specification_version: 4
173
45
  summary: Expectation result presenter.
174
46
  test_files: []