spectus 4.0.3 → 5.0.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: 3d2dc0863871f3794105ca9de38893d86ca937fe09bc8f90772d22f23551db79
4
- data.tar.gz: efda8aae27fb68317b3d450ede09c13e22c7d5c8e638ba8c8fd8169ce5b93f03
3
+ metadata.gz: 3f0cce51d702c1c3d143fdad6af9384ebe7cbca8718a671d928ca8b5a111fe04
4
+ data.tar.gz: 1648b947935ac87ef6c5b02c16a066b92bf44bbcf5d8bfae0d87c07d3697cf91
5
5
  SHA512:
6
- metadata.gz: 07e371fdb35d33e5451ca8188be95e153d08e58b0e32791081ecfed6d42a7eb16917ed711cff89bcaca7e27b2b10a59ba6676e1896e7f6cd15eb255861c1f2d4
7
- data.tar.gz: 777d8c69e1beede896cd074c3c839707497a6775fe2e4263f309d66128a25b914beeee4ae822fa43c58d0b6279215c0f8a39ffe08b595ced35cdf02714e15a4e
6
+ metadata.gz: 165ed9b4d2528c514dcf9856124a9da2d43c414757e2bd31716b9098f9fa55c5b4f9db4d65f35a0b94696c9bde2143c40a7285ddc428171496b1f56d285ac87f
7
+ data.tar.gz: 8c4a74459502da707d751ac829efccd41bdb9f49667eb7b94d460f93fbf427b25e7c888d16c207889366bb56e51f58ccad6e3716c2709bb28d2af4d5dd985bee
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014-2021 Cyril Kato
3
+ Copyright (c) 2014-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,14 @@
1
1
  # Spectus
2
2
 
3
- [![Version](https://img.shields.io/github/v/tag/fixrb/spectus?label=Version&logo=github)](https://github.com/fixrb/spectus/releases)
3
+ [![Version](https://img.shields.io/github/v/tag/fixrb/spectus?label=Version&logo=github)](https://github.com/fixrb/spectus/tags)
4
4
  [![Yard documentation](https://img.shields.io/badge/Yard-documentation-blue.svg?logo=github)](https://rubydoc.info/github/fixrb/spectus/main)
5
- [![CI](https://github.com/fixrb/spectus/workflows/CI/badge.svg?branch=main)](https://github.com/fixrb/spectus/actions?query=workflow%3Aci+branch%3Amain)
5
+ [![Ruby](https://github.com/fixrb/spectus/workflows/Ruby/badge.svg?branch=main)](https://github.com/fixrb/spectus/actions?query=workflow%3Aruby+branch%3Amain)
6
6
  [![RuboCop](https://github.com/fixrb/spectus/workflows/RuboCop/badge.svg?branch=main)](https://github.com/fixrb/spectus/actions?query=workflow%3Arubocop+branch%3Amain)
7
7
  [![License](https://img.shields.io/github/license/fixrb/spectus?label=License&logo=github)](https://github.com/fixrb/spectus/raw/main/LICENSE.md)
8
8
 
9
- > Expectation library with [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt) requirement levels 🚥
9
+ > A Ruby library for defining expectations with precision, using [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt) compliance levels. 🚥
10
+
11
+ ![A traffic light with three distinct sections](https://github.com/fixrb/spectus/raw/main/img/spectus.png)
10
12
 
11
13
  ## Installation
12
14
 
@@ -19,7 +21,7 @@ gem "spectus"
19
21
  And then execute:
20
22
 
21
23
  ```sh
22
- bundle
24
+ bundle install
23
25
  ```
24
26
 
25
27
  Or install it yourself as:
@@ -113,43 +115,11 @@ My bad! ActiveSupport was not imported. 🤦‍♂️
113
115
 
114
116
  Anyways, the test passes because the exception produced is `NoMethodError`, meaning that the functionality is not implemented.
115
117
 
116
- ## Code Isolation
117
-
118
- When executing expectations, side-effects may occur.
119
- Because they may or may not be desired, each requirement level has 2 versions:
120
-
121
- * if it does not end with `!`, its test is performed without isolation;
122
- * if it ends with `!`, its test is performed in isolation.
123
-
124
- Example of test without isolation:
125
-
126
- ```ruby
127
- greeting = "Hello, world!"
128
-
129
- definition = Spectus.must Matchi::Eq.new("Hello, Alice!")
130
- definition.call { greeting.gsub!("world", "Alice") }
131
- # => Expresenter::Pass(actual: "Hello, Alice!", definition: "eq \"Hello, Alice!\"", error: nil, expected: "Hello, Alice!", got: true, negate: false, level: :MUST)
132
-
133
- greeting # => "Hello, Alice!"
134
- ```
135
-
136
- Example of test in isolation:
137
-
138
- ```ruby
139
- greeting = "Hello, world!"
140
-
141
- definition = Spectus.must! Matchi::Eq.new("Hello, Alice!")
142
- definition.call { greeting.gsub!("world", "Alice") }
143
- # => Expresenter::Pass(actual: "Hello, Alice!", definition: "eq \"Hello, Alice!\"", error: nil, expected: "Hello, Alice!", got: true, negate: false, level: :MUST)
144
-
145
- greeting # => "Hello, world!"
146
- ```
147
-
148
118
  ## Contact
149
119
 
150
120
  * Home page: https://github.com/fixrb/spectus
151
121
  * Bugs/issues: https://github.com/fixrb/spectus/issues
152
- * Blog post: https://batman.buzz/a-spectus-tutorial-expectations-with-rfc-2119-compliance-1fc769861c1
122
+ * Blog post: https://cyrilllllll.medium.com/a-spectus-tutorial-expectations-with-rfc-2119-compliance-1fc769861c1
153
123
 
154
124
  ## Versioning
155
125
 
@@ -159,11 +129,11 @@ __Spectus__ follows [Semantic Versioning 2.0](https://semver.org/).
159
129
 
160
130
  The [gem](https://rubygems.org/gems/spectus) is available as open source under the terms of the [MIT License](https://github.com/fixrb/spectus/raw/main/LICENSE.md).
161
131
 
162
- ***
132
+ ---
163
133
 
164
134
  <p>
165
135
  This project is sponsored by:<br />
166
136
  <a href="https://sashite.com/"><img
167
137
  src="https://github.com/fixrb/spectus/raw/main/img/sashite.png"
168
- alt="Sashite" /></a>
138
+ alt="Sashité" /></a>
169
139
  </p>
@@ -10,11 +10,9 @@ module Spectus
10
10
  class Base
11
11
  # Initialize the requirement level class.
12
12
  #
13
- # @param isolate [Boolean] Compute actual in a subprocess.
14
13
  # @param matcher [#matches?] The matcher.
15
14
  # @param negate [Boolean] Invert the matcher or not.
16
- def initialize(isolate:, matcher:, negate:)
17
- @isolate = isolate
15
+ def initialize(matcher:, negate:)
18
16
  @matcher = matcher
19
17
  @negate = negate
20
18
  end
@@ -27,8 +25,8 @@ module Spectus
27
25
  # @see https://github.com/fixrb/expresenter
28
26
  #
29
27
  # @api public
30
- def call(&block)
31
- test = ::TestTube.invoke(isolate: @isolate, matcher: @matcher, negate: @negate, &block)
28
+ def call(&)
29
+ test = ::TestTube.invoke(matcher: @matcher, negate: @negate, &)
32
30
 
33
31
  ::Expresenter.call(passed?(test)).with(
34
32
  actual: test.actual,
@@ -51,13 +49,13 @@ module Spectus
51
49
  #
52
50
  # definition = Spectus.must Matchi::Be.new(1)
53
51
  # definition.inspect
54
- # # => "#<MUST Matchi::Be(1) isolate=false negate=false>"
52
+ # # => "#<MUST Matchi::Be(1) negate=false>"
55
53
  #
56
54
  # @return [String] The human-readable representation of the definition.
57
55
  #
58
56
  # @api public
59
57
  def inspect
60
- "#<#{self.class.level} #{@matcher.inspect} isolate=#{@isolate} negate=#{@negate}>"
58
+ "#<#{self.class.level} #{@matcher.inspect} negate=#{@negate}>"
61
59
  end
62
60
 
63
61
  # :nocov:
data/lib/spectus.rb CHANGED
@@ -15,7 +15,7 @@ module Spectus
15
15
  # require "matchi/eq"
16
16
  #
17
17
  # Spectus.must Matchi::Eq.new("FOO")
18
- # # => #<MUST Matchi::Eq("FOO") isolate=false negate=false>
18
+ # # => #<MUST Matchi::Eq("FOO") negate=false>
19
19
  #
20
20
  # @param matcher [#matches?] The matcher.
21
21
  #
@@ -23,27 +23,7 @@ module Spectus
23
23
  #
24
24
  # @api public
25
25
  def self.must(matcher)
26
- Requirement::Required.new(
27
- isolate: false,
28
- negate: false,
29
- matcher: matcher
30
- )
31
- end
32
-
33
- # @example An absolute requirement definition with isolation
34
- # require "spectus"
35
- # require "matchi/eq"
36
- #
37
- # Spectus.must! Matchi::Eq.new("FOO")
38
- # # => #<MUST Matchi::Eq("FOO") isolate=true negate=false>
39
- #
40
- # @see must
41
- def self.must!(matcher)
42
- Requirement::Required.new(
43
- isolate: true,
44
- negate: false,
45
- matcher: matcher
46
- )
26
+ Requirement::Required.new(negate: false, matcher:)
47
27
  end
48
28
 
49
29
  # This method mean that the definition is an absolute prohibition of the specification.
@@ -53,33 +33,13 @@ module Spectus
53
33
  # require "matchi/be"
54
34
  #
55
35
  # Spectus.must_not Matchi::Be.new(42)
56
- # # => #<MUST Matchi::Be(42) isolate=false negate=true>
36
+ # # => #<MUST Matchi::Be(42) negate=true>
57
37
  #
58
38
  # @param matcher [#matches?] The matcher.
59
39
  #
60
40
  # @return [Requirement::Required] An absolute prohibition level instance.
61
41
  def self.must_not(matcher)
62
- Requirement::Required.new(
63
- isolate: false,
64
- negate: true,
65
- matcher: matcher
66
- )
67
- end
68
-
69
- # @example An absolute prohibition definition with isolation
70
- # require "spectus"
71
- # require "matchi/be"
72
- #
73
- # Spectus.must_not! Matchi::Be.new(42)
74
- # # => #<MUST Matchi::Be(42) isolate=true negate=true>
75
- #
76
- # @see must_not
77
- def self.must_not!(matcher)
78
- Requirement::Required.new(
79
- isolate: true,
80
- negate: true,
81
- matcher: matcher
82
- )
42
+ Requirement::Required.new(negate: true, matcher:)
83
43
  end
84
44
 
85
45
  # This method mean that there may exist valid reasons in particular
@@ -91,33 +51,13 @@ module Spectus
91
51
  # require "matchi/be"
92
52
  #
93
53
  # Spectus.should Matchi::Be.new(true)
94
- # # => #<SHOULD Matchi::Be(true) isolate=false negate=false>
54
+ # # => #<SHOULD Matchi::Be(true) negate=false>
95
55
  #
96
56
  # @param matcher [#matches?] The matcher.
97
57
  #
98
58
  # @return [Requirement::Recommended] A recommended requirement level instance.
99
59
  def self.should(matcher)
100
- Requirement::Recommended.new(
101
- isolate: false,
102
- negate: false,
103
- matcher: matcher
104
- )
105
- end
106
-
107
- # @example A recommended definition with isolation
108
- # require "spectus"
109
- # require "matchi/be"
110
- #
111
- # Spectus.should! Matchi::Be.new(true)
112
- # # => #<SHOULD Matchi::Be(true) isolate=true negate=false>
113
- #
114
- # @see should
115
- def self.should!(matcher)
116
- Requirement::Recommended.new(
117
- isolate: true,
118
- negate: false,
119
- matcher: matcher
120
- )
60
+ Requirement::Recommended.new(negate: false, matcher:)
121
61
  end
122
62
 
123
63
  # This method mean that there may exist valid reasons in particular
@@ -130,34 +70,14 @@ module Spectus
130
70
  # require "matchi/raise_exception"
131
71
  #
132
72
  # Spectus.should_not Matchi::RaiseException.new(NoMethodError)
133
- # # => #<SHOULD Matchi::RaiseException(NoMethodError) isolate=false negate=true>
73
+ # # => #<SHOULD Matchi::RaiseException(NoMethodError) negate=true>
134
74
  #
135
75
  # @param matcher [#matches?] The matcher.
136
76
  #
137
77
  # @return [Requirement::Recommended] A not recommended requirement level
138
78
  # instance.
139
79
  def self.should_not(matcher)
140
- Requirement::Recommended.new(
141
- isolate: false,
142
- negate: true,
143
- matcher: matcher
144
- )
145
- end
146
-
147
- # @example A not recommended definition with isolation
148
- # require "spectus"
149
- # require "matchi/raise_exception"
150
- #
151
- # Spectus.should_not! Matchi::RaiseException.new(NoMethodError)
152
- # # => #<SHOULD Matchi::RaiseException(NoMethodError) isolate=true negate=true>
153
- #
154
- # @see should_not
155
- def self.should_not!(matcher)
156
- Requirement::Recommended.new(
157
- isolate: true,
158
- negate: true,
159
- matcher: matcher
160
- )
80
+ Requirement::Recommended.new(negate: true, matcher:)
161
81
  end
162
82
 
163
83
  # This method mean that an item is truly optional.
@@ -176,32 +96,12 @@ module Spectus
176
96
  # require "matchi/match"
177
97
  #
178
98
  # Spectus.may Matchi::Match.new(/^foo$/)
179
- # # => #<MAY Matchi::Match(/^foo$/) isolate=false negate=false>
99
+ # # => #<MAY Matchi::Match(/^foo$/) negate=false>
180
100
  #
181
101
  # @param matcher [#matches?] The matcher.
182
102
  #
183
103
  # @return [Requirement::Optional] An optional requirement level instance.
184
104
  def self.may(matcher)
185
- Requirement::Optional.new(
186
- isolate: false,
187
- negate: false,
188
- matcher: matcher
189
- )
190
- end
191
-
192
- # @example An optional definition with isolation
193
- # require "spectus"
194
- # require "matchi/match"
195
- #
196
- # Spectus.may! Matchi::Match.new(/^foo$/)
197
- # # => #<MAY Matchi::Match(/^foo$/) isolate=true negate=false>
198
- #
199
- # @see may
200
- def self.may!(matcher)
201
- Requirement::Optional.new(
202
- isolate: true,
203
- negate: false,
204
- matcher: matcher
205
- )
105
+ Requirement::Optional.new(negate: false, matcher:)
206
106
  end
207
107
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spectus
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.3
4
+ version: 5.0.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-07-31 00:00:00.000000000 Z
11
+ date: 2024-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: expresenter
@@ -16,168 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.4.0
19
+ version: 1.4.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.4.0
26
+ version: 1.4.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: test_tube
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.1.1
33
+ version: 3.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.1.1
41
- - !ruby/object:Gem::Dependency
42
- name: brutal
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: bundler
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: matchi
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: 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-md
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: rubocop-performance
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: rubocop-rake
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'
139
- - !ruby/object:Gem::Dependency
140
- name: rubocop-thread_safety
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: simplecov
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
- - !ruby/object:Gem::Dependency
168
- name: yard
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: '0'
40
+ version: 3.0.0
181
41
  description: "Expectation library with RFC 2119's requirement levels \U0001F6A5"
182
42
  email: contact@cyril.email
183
43
  executables: []
@@ -195,7 +55,8 @@ files:
195
55
  homepage: https://github.com/fixrb/spectus
196
56
  licenses:
197
57
  - MIT
198
- metadata: {}
58
+ metadata:
59
+ rubygems_mfa_required: 'true'
199
60
  post_install_message:
200
61
  rdoc_options: []
201
62
  require_paths:
@@ -204,14 +65,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
204
65
  requirements:
205
66
  - - ">="
206
67
  - !ruby/object:Gem::Version
207
- version: 2.7.0
68
+ version: 3.2.0
208
69
  required_rubygems_version: !ruby/object:Gem::Requirement
209
70
  requirements:
210
71
  - - ">="
211
72
  - !ruby/object:Gem::Version
212
73
  version: '0'
213
74
  requirements: []
214
- rubygems_version: 3.1.6
75
+ rubygems_version: 3.4.19
215
76
  signing_key:
216
77
  specification_version: 4
217
78
  summary: "Expectation library with RFC 2119's requirement levels \U0001F6A5"