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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba078df3937d6f069a4ed24e9aaed9617dc1eb03139be0189e51b060b11a75ba
4
- data.tar.gz: 0fe77f31d282754df6712aafae7995e82e99d9ee86f8ad12bd060596147dafe1
3
+ metadata.gz: 117dfaa6197dcb53fd6619ae414452a277d668a34736331169407361dbdcb0bc
4
+ data.tar.gz: 86a17a6070762151d0e84010c3bdf75569df962c1428fb7008f46cfe685f312c
5
5
  SHA512:
6
- metadata.gz: e49791f3e5a380e822f4d86f39444a09e26828c4b1ea7c90d298c9eedcc14d8c6fdc05864439e1984b0cead4183beb1ae108bee82c7ce6dccbe11aae5efbd248
7
- data.tar.gz: cddd15cf550e166ec93d15fa2ffdf07a68646aa6750d544b6a5cf64c9bfb44177b638e6ff1df2ce25e28105df05aa838534e6eaafadefb7688aed32dae9d3bbc
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
- ruby-version: ['2.5', '2.6', '2.7', '3.0']
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
- run: bundle exec rake
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 2.7.1
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)
@@ -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 = Random.new
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
- # >> Generators.choose(0..100).with_config.map { |int, conf| Date.jd(conf[:default_epoch].jd + int) }.call(size: 10, rng: Random.new(42), config: PropCheck::Property::Configuration.new)
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|
@@ -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)
@@ -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::DEFAULT
335
+ rng = Random.new
336
336
  size = 1
337
337
  (0...@config.max_generate_attempts)
338
338
  .lazy
@@ -1,3 +1,3 @@
1
1
  module PropCheck
2
- VERSION = '0.18.0'
2
+ VERSION = '0.18.1'
3
3
  end
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.0
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: 2022-11-22 00:00:00.000000000 Z
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.2.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.