r_spec-clone 1.4.0 → 1.5.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 +16 -1
- data/lib/r_spec/clone/expectation_helper/it.rb +1 -1
- data/lib/r_spec/clone/expectation_helper/shared.rb +33 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef1c79c6783a2aace9f035ef5935bb556828731501ce7b92f86dcedf58e18d90
|
4
|
+
data.tar.gz: 615131453af20ba74f436f0569db9f429af2bd18589de5ee132ef69af8cd09d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbaa63b25dc7a3d98810d686d5fb4a5cacec5a74ac04d1aab01f86dfc886ef57cf9b9ae20201aaf3a43e95bb626ce363bfe62190142904ceef8526d1d34ef9ab
|
7
|
+
data.tar.gz: e6b4d19ef401aa923f31739ab5ee5289929309d762113f82d361f52859c17f24739e18f8236e93db6d47f428e1f09a6aa4c6beabfb5ea938f0fa1f6769cf4835
|
data/README.md
CHANGED
@@ -180,9 +180,24 @@ expect(actual).to be_instance_of(expected) # passes if expected.equal?(actual
|
|
180
180
|
expect(actual).to be_an_instance_of(expected) # passes if expected.equal?(actual.class)
|
181
181
|
```
|
182
182
|
|
183
|
+
#### Predicate
|
184
|
+
|
185
|
+
```ruby
|
186
|
+
expect(actual).to be_xxx # passes if actual.xxx?
|
187
|
+
expect(actual).to be_have_xxx(:yyy) # passes if actual.has_xxx?(:yyy)
|
188
|
+
```
|
189
|
+
|
190
|
+
##### Examples
|
191
|
+
|
192
|
+
```ruby
|
193
|
+
expect([]).to be_empty
|
194
|
+
expect(foo: 1).to have_key(:foo)
|
195
|
+
```
|
196
|
+
|
183
197
|
#### Change
|
184
198
|
|
185
199
|
```ruby
|
200
|
+
expect { object.action }.to change(object, :value).to(new)
|
186
201
|
expect { object.action }.to change(object, :value).from(old).to(new)
|
187
202
|
expect { object.action }.to change(object, :value).by(delta)
|
188
203
|
expect { object.action }.to change(object, :value).by_at_least(minimum_delta)
|
@@ -269,7 +284,7 @@ Benchmark against [100 executions of a file containing 1 expectation](https://gi
|
|
269
284
|
|
270
285
|
### Runtime
|
271
286
|
|
272
|
-
Benchmark against [1 execution of a file containing
|
287
|
+
Benchmark against [1 execution of a file containing 100,000 expectations](https://github.com/cyril/r_spec-clone.rb/blob/main/benchmark/run_time/) (lower is better).
|
273
288
|
|
274
289
|

|
275
290
|
|
@@ -19,7 +19,7 @@ module RSpec
|
|
19
19
|
#
|
20
20
|
# @example
|
21
21
|
# expect("foo") # => #<RSpec::Clone::ExpectationTarget::Value:0x00007f @actual="foo">
|
22
|
-
# expect { Boom } # => #<RSpec::Clone::ExpectationTarget::Block:
|
22
|
+
# expect { RSpec::Clone::Boom! } # => #<RSpec::Clone::ExpectationTarget::Block:0x... @callable=#<Proc:0x...>>
|
23
23
|
#
|
24
24
|
# @api public
|
25
25
|
def expect(value = self.class.superclass, &block)
|
@@ -87,7 +87,7 @@ module RSpec
|
|
87
87
|
#
|
88
88
|
# @example
|
89
89
|
# matcher = raise_exception(NameError)
|
90
|
-
# matcher.matches? { Boom } # => true
|
90
|
+
# matcher.matches? { RSpec::Clone::Boom! } # => true
|
91
91
|
# matcher.matches? { true } # => false
|
92
92
|
#
|
93
93
|
# @param expected [Exception, #to_s] The expected exception name.
|
@@ -212,6 +212,38 @@ module RSpec
|
|
212
212
|
def satisfy(&expected)
|
213
213
|
::Matchi::Satisfy.new(&expected)
|
214
214
|
end
|
215
|
+
|
216
|
+
private
|
217
|
+
|
218
|
+
# Predicate matcher, or default method missing behavior.
|
219
|
+
#
|
220
|
+
# @example Empty predicate matcher
|
221
|
+
# matcher = be_empty
|
222
|
+
# matcher.matches? { [] } # => true
|
223
|
+
# matcher.matches? { [4] } # => false
|
224
|
+
def method_missing(name, *args, **kwargs, &block)
|
225
|
+
return super unless predicate_matcher_name?(name)
|
226
|
+
|
227
|
+
::Matchi::Predicate.new(name, *args, **kwargs, &block)
|
228
|
+
end
|
229
|
+
|
230
|
+
# :nocov:
|
231
|
+
|
232
|
+
# Hook method to return whether the obj can respond to id method or not.
|
233
|
+
def respond_to_missing?(name, include_private = false)
|
234
|
+
predicate_matcher_name?(name) || super
|
235
|
+
end
|
236
|
+
|
237
|
+
# :nocov:
|
238
|
+
|
239
|
+
# Predicate matcher name detector.
|
240
|
+
#
|
241
|
+
# @param name [Array, Symbol] The name of a potential predicate matcher.
|
242
|
+
#
|
243
|
+
# @return [Boolean] Indicates if it is a predicate matcher name or not.
|
244
|
+
def predicate_matcher_name?(name)
|
245
|
+
name.start_with?("be_", "have_") && !name.end_with?("!", "?")
|
246
|
+
end
|
215
247
|
end
|
216
248
|
end
|
217
249
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: r_spec-clone
|
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
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: expresenter
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 3.
|
33
|
+
version: 3.3.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: 3.
|
40
|
+
version: 3.3.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: test_tube
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|