prop_check 0.18.0 → 0.18.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/run_tests.yaml +8 -3
- data/.tool-versions +1 -1
- data/CHANGELOG.md +5 -0
- data/lib/prop_check/generator.rb +11 -2
- data/lib/prop_check/helper.rb +3 -0
- data/lib/prop_check/property.rb +1 -1
- data/lib/prop_check/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 117dfaa6197dcb53fd6619ae414452a277d668a34736331169407361dbdcb0bc
|
4
|
+
data.tar.gz: 86a17a6070762151d0e84010c3bdf75569df962c1428fb7008f46cfe685f312c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d00f635551fc17b870a0f3065040662b85565a19a498d84dbdb76de106f0138d905f2da0fdb89f5ee25e666411abdc7d4d7b61831114d99ed80451471f450f0
|
7
|
+
data.tar.gz: 8ec326b8e39ceed7d587de59c6fac591e91d4429bdef0a9770542643e7a1d5323667f59cf196611cac42324288994096054afc72ea6eb2722640a68c3cc745b6
|
@@ -15,7 +15,8 @@ jobs:
|
|
15
15
|
runs-on: ubuntu-latest
|
16
16
|
strategy:
|
17
17
|
matrix:
|
18
|
-
|
18
|
+
# NOTE: Ruby 3.2 is not in here, as `doctest-core` first needs to be updated to support it
|
19
|
+
ruby-version: ['2.6', '2.7', '3.0', '3.1']
|
19
20
|
|
20
21
|
steps:
|
21
22
|
- uses: actions/checkout@v3
|
@@ -27,5 +28,9 @@ jobs:
|
|
27
28
|
with:
|
28
29
|
ruby-version: ${{ matrix.ruby-version }}
|
29
30
|
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
30
|
-
- name: Run tests
|
31
|
-
|
31
|
+
- name: Run tests & push test coverage to Codeclimate
|
32
|
+
uses: paambaati/codeclimate-action@v3.2.0
|
33
|
+
env:
|
34
|
+
CC_TEST_REPORTER_ID: '9d18f5b43e49eecd6c3da64d85ea9c765d3606c129289d7c8cadf6d448713311'
|
35
|
+
with:
|
36
|
+
coverageCommand: bundle exec rake
|
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby
|
1
|
+
ruby 3.1.3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
- 0.18.1
|
2
|
+
- Fixes:
|
3
|
+
- Compatibility with Ruby 3.2:
|
4
|
+
- Use `Random` instead of no-longer-available `Random::DEFAULT` on Ruby 3.x.
|
5
|
+
- Ensure when a hash is passed (such as in `PropCheck.forall(hash_of(integer, string)) { |hash| ... }` that when an empty hash is generated, `hash` is still `{}` and not `nil`. ([Ruby 3.x treats `fun(**{})` differently than Ruby 2.x](https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/#other-minor-changes-empty-hash))
|
1
6
|
- 0.18.0
|
2
7
|
- Features:
|
3
8
|
- Allows calling `PropCheck::Property#check` without a block, which will just return `self`. This is useful for writing wrapper functions that use `before/after/around/with_config` etc hooks which might themselves optionally want a block so they can be chained. (See the `forall_with_db` snippet in the README for an example)
|
data/lib/prop_check/generator.rb
CHANGED
@@ -9,7 +9,14 @@ module PropCheck
|
|
9
9
|
# to be used during the shrinking phase.
|
10
10
|
class Generator
|
11
11
|
@@default_size = 10
|
12
|
-
@@default_rng =
|
12
|
+
@@default_rng =
|
13
|
+
# Backwards compatibility: Random::DEFAULT is deprecated in Ruby 3.x
|
14
|
+
# but required in Ruby 2.x and 1.x
|
15
|
+
if RUBY_VERSION.to_i >= 3
|
16
|
+
Random
|
17
|
+
else
|
18
|
+
Random::DEFAULT
|
19
|
+
end
|
13
20
|
@@max_consecutive_attempts = 100
|
14
21
|
@@default_kwargs = { size: @@default_size, rng: @@default_rng,
|
15
22
|
max_consecutive_attempts: @@max_consecutive_attempts }
|
@@ -115,7 +122,9 @@ module PropCheck
|
|
115
122
|
# This can be used to inspect the configuration inside a `#map` or `#where`
|
116
123
|
# and act on it.
|
117
124
|
#
|
118
|
-
# >>
|
125
|
+
# >> example_config = PropCheck::Property::Configuration.new(default_epoch: Date.new(2022, 11, 22))
|
126
|
+
# >> generator = Generators.choose(0..100).with_config.map { |int, conf| Date.jd(conf[:default_epoch].jd + int) }
|
127
|
+
# >> generator.call(size: 10, rng: Random.new(42), config: example_config)
|
119
128
|
# => Date.new(2023, 01, 12)
|
120
129
|
def with_config
|
121
130
|
Generator.new do |**kwargs|
|
data/lib/prop_check/helper.rb
CHANGED
@@ -33,6 +33,9 @@ module PropCheck
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def call_splatted(val, &block)
|
36
|
+
# Handle edge case where Ruby >= 3 behaves differently than Ruby <= 2
|
37
|
+
# c.f. https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/#other-minor-changes-empty-hash
|
38
|
+
return block.call({}) if val.is_a?(Hash) && val.empty?
|
36
39
|
return block.call(**val) if val.is_a?(Hash) && val.keys.all? { |k| k.is_a?(Symbol) }
|
37
40
|
|
38
41
|
block.call(val)
|
data/lib/prop_check/property.rb
CHANGED
@@ -332,7 +332,7 @@ c.f. https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-k
|
|
332
332
|
end
|
333
333
|
|
334
334
|
private def raw_attempts_enum(binding_generator)
|
335
|
-
rng = Random
|
335
|
+
rng = Random.new
|
336
336
|
size = 1
|
337
337
|
(0...@config.max_generate_attempts)
|
338
338
|
.lazy
|
data/lib/prop_check/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prop_check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.18.
|
4
|
+
version: 0.18.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Qqwy/Wiebe-Marten Wijnja
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: amazing_print
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
|
-
rubygems_version: 3.
|
86
|
+
rubygems_version: 3.3.26
|
87
87
|
signing_key:
|
88
88
|
specification_version: 4
|
89
89
|
summary: PropCheck allows you to do property-based testing, including shrinking.
|