README.md in prop_check-0.18.1 vs README.md in prop_check-0.18.2

- old
+ new

@@ -154,10 +154,27 @@ end end end ``` +The test case, using test-unit: +``` ruby +require "test-unit" + +class TestNaiveAverage < Test::Unit::TestCase + G = PropCheck::Generators + + def test_that_it_returns_an_integer_for_any_input + PropCheck.forall(G.array(G.integer)) do |numbers| + result = naive_average(numbers) + + assert_instance_of(Integer, result) + end + end +end +``` + The test case, using only vanilla Ruby: ```ruby # And then in a test case: G = PropCheck::Generators @@ -248,11 +265,11 @@ #### Generator#map Allows you to take the result of one generator and transform it into something else. - >> G.choose(32..128).map(&:chr).sample(1, size: 10, Random.new(42)) + >> G.choose(32..128).map(&:chr).sample(1, size: 10, rng: Random.new(42)) => ["S"] #### Generator#bind Allows you to create one or another generator conditionally on the output of another generator. @@ -260,11 +277,11 @@ >> G.integer.bind { |a| G.integer.bind { |b| G.constant([a , b]) } }.sample(1, size: 100, rng: Random.new(42) => [[2, 79]] This is an advanced feature. Often, you can use a combination of `Generators.tuple` and `Generator#map` instead: - >> G.tuple(integer, integer).sample(1, size: 100, rng: Random.new(42) + >> G.tuple(G.integer, G.integer).sample(1, size: 100, rng: Random.new(42)) => [[2, 79]] #### Generators.one_of Useful if you want to be able to generate a value to be one of multiple possibilities: @@ -307,16 +324,20 @@ .before { DatabaseCleaner.start } .after { DatabaseCleaner.clean } .check(&block) end ``` -- Other setup/cleanup should also usually happen around each generated example rather than around the whole test: Instead of using the hooks exposed by RSpec/MiniTest/etc., use the before/after/around hooks exposed by PropCheck. +- Other setup/cleanup should also usually happen around each generated example rather than around the whole test: Instead of using the hooks exposed by RSpec/MiniTest/test-unit/etc., use the before/after/around hooks exposed by PropCheck. ## Development -After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. +After checking out the repo, use the [just](https://github.com/casey/just) command runner for common tasks: -To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). +- `just setup`: Installs dev dependencies +- `just test`: Runs the test suite +- `just console`: Opens an IRb console with the gem loaded for experimenting. +- `just install`: Install the gem on your local machine. +- `just release`: Create and push a new release to the git repo and Rubygems. (Be sure to increase the version number in `version.rb` first!) ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/Qqwy/ruby-prop_check . This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.