Module: Pbt::Check::RunnerMethods

Includes:
Tosser
Included in:
Pbt
Defined in:
lib/pbt/check/runner_methods.rb

Overview

Module to be

Instance Method Summary collapse

Methods included from Tosser

#toss

Instance Method Details

#assert(**options, &property) ⇒ void

This method returns an undefined value.

Run a property based test and report its result.

Parameters:

  • options (Hash)

    Optional parameters to customize the execution.

  • property (Proc)

    Proc that returns Property instance.

Raises:

See Also:



21
22
23
24
# File 'lib/pbt/check/runner_methods.rb', line 21

def assert(**options, &property)
  out = check(**options, &property)
  Reporter::RunDetailsReporter.new(out).report_run_details
end

#check(**options, &property) ⇒ RunDetails

Run a property based test and return its result. This doesn’t throw contrary to ‘assert`. Use `assert` unless you want to handle the result.

Parameters:

  • options (Hash)

    Optional parameters to customize the execution.

  • property (Proc)

    Proc that returns Property instance.

Returns:

  • (RunDetails)

See Also:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/pbt/check/runner_methods.rb', line 35

def check(**options, &property)
  property = property.call
  config = Pbt.configuration.to_h.merge(options.to_h)

  initial_values = toss(property, config[:seed])
  source_values = Enumerator.new(config[:num_runs]) do |y|
    config[:num_runs].times do
      y.yield initial_values.next
    end
  end

  suppress_exception_report_for_ractor(config) do
    run_it(property, source_values, config).to_run_details(config)
  end
end