README.md in prop_check-0.9.0 vs README.md in prop_check-0.10.0

- old
+ new

@@ -25,10 +25,11 @@ - [x] Customize the max. of samples to run. - [x] Stop after a ludicrous amount of generator runs, to prevent malfunctioning (infinitely looping) generators from blowing up someone's computer. - [x] Look into customization of settings from e.g. command line arguments. - [x] Good, unicode-compliant, string generators. - [x] Filtering generator outputs. +- [x] Before/after/around hooks to add setup/teardown logic to be called before/after/around each time a check is run with new data. # Nice-to-haves - [x] Basic integration with RSpec. See also https://groups.google.com/forum/#!msg/rspec/U-LmL0OnO-Y/iW_Jcd6JBAAJ for progress on this. - [ ] `aggregate` , `resize` and similar generator-modifying calls (c.f. PropEr's variants of these) which will help with introspection/metrics. @@ -85,16 +86,30 @@ ```ruby # Somewhere you have this function definition: def naive_average(array) array.sum / array.length end - +``` +```ruby # And then in a test case: include PropCheck::Generators PropCheck.forall(numbers: array(integer)) do |numbers:| result = naive_average(numbers) unless result.is_a?(Integer) do raise "Expected the average to be an integer!" + end +end + +# Or if you e.g. are using RSpec: +describe "#naive_average" do + include PropCheck + include PropCheck::Generators + + it "returns an integer for any input" do + forall(numbers: array(integer)) do |numbers:| + result = naive_average(numbers) + expect(result).to be_a(Integer) + end end end ``` When running this particular example PropCheck very quickly finds out that we have made a programming mistake: