ohbarye / pbt

Property-Based Testing tool for Ruby, supporting multiple concurrency methods (Ractor, multiprocesses, multithreads).
https://rubygems.org/gems/pbt
MIT License
207 stars 4 forks source link

Improve error handle #25

Closed ohbarye closed 5 months ago

ohbarye commented 5 months ago

Change

  1. Make error messages short to keep focusing on error causes.
  2. Do not exit on RSpec::Expectations::ExpectationNotMetError that inherits Exception so that pbt continues shrinking phase.
RSpec.describe Pbt do
  it "sorts an array" do
    Pbt.assert do
      Pbt.property(Pbt.array(Pbt.integer)) do |numbers|
        result = sort(numbers)
        result.each_cons(2) do |x, y|
          expect(x).to be <= y
        end
      end
    end
  end
end