Class: PropCheck::Property::Configuration

Inherits:
Struct
  • Object
show all
Defined in:
lib/prop_check/property/configuration.rb

Overview

Configure PropCheck

Configurations can be set globally, but also overridden on a per-generator basis. c.f. PropCheck.configure, PropCheck.configuration and PropCheck::Property#with_config

## Available options

  • ‘verbose:` When true, shows detailed options of the data generation and shrinking process. (Default: false)

  • ‘n_runs:` The amount of iterations each `forall` is being run.

  • ‘max_generate_attempts:` The amount of times the library tries a generator in total

    before raising `Errors::GeneratorExhaustedError`. c.f. `PropCheck::Generator#where`. (Default: 10_000)
    
  • ‘max_shrink_steps:` The amount of times shrinking is attempted. (Default: 10_000)

  • ‘max_consecutive_attempts:`

  • ‘max_consecutive_attempts:` The amount of times the library tries a filtered generator consecutively

    again before raising `Errors::GeneratorExhaustedError`. c.f. `PropCheck::Generator#where`. (Default: 10_000)
    
  • ‘default_epoch:` The ’base’ value to use for date/time generators like

    `PropCheck::Generators#date` `PropCheck::Generators#future_date` `PropCheck::Generators#time`, etc.
    (Default: `DateTime.now`)
    
  • ‘resize_function` A proc that can be used to resize all generators.

    Takes the current size as integer and should return a new integer.
    

    (Default: ‘proc { |size| size }`)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(verbose: false, n_runs: 100, max_generate_attempts: 10_000, max_shrink_steps: 10_000, max_consecutive_attempts: 30, default_epoch: DateTime.now, resize_function: proc { |size| size }) ⇒ Configuration

Returns a new instance of Configuration.



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/prop_check/property/configuration.rb', line 34

def initialize(
  verbose: false,
  n_runs: 100,
  max_generate_attempts: 10_000,
  max_shrink_steps: 10_000,
  max_consecutive_attempts: 30,
  default_epoch: DateTime.now,
  resize_function: proc { |size| size }
)
  super
end

Instance Attribute Details

#default_epochObject

Returns the value of attribute default_epoch

Returns:

  • (Object)

    the current value of default_epoch



24
25
26
# File 'lib/prop_check/property/configuration.rb', line 24

def default_epoch
  @default_epoch
end

#max_consecutive_attemptsObject

Returns the value of attribute max_consecutive_attempts

Returns:

  • (Object)

    the current value of max_consecutive_attempts



24
25
26
# File 'lib/prop_check/property/configuration.rb', line 24

def max_consecutive_attempts
  @max_consecutive_attempts
end

#max_generate_attemptsObject

Returns the value of attribute max_generate_attempts

Returns:

  • (Object)

    the current value of max_generate_attempts



24
25
26
# File 'lib/prop_check/property/configuration.rb', line 24

def max_generate_attempts
  @max_generate_attempts
end

#max_shrink_stepsObject

Returns the value of attribute max_shrink_steps

Returns:

  • (Object)

    the current value of max_shrink_steps



24
25
26
# File 'lib/prop_check/property/configuration.rb', line 24

def max_shrink_steps
  @max_shrink_steps
end

#n_runsObject

Returns the value of attribute n_runs

Returns:

  • (Object)

    the current value of n_runs



24
25
26
# File 'lib/prop_check/property/configuration.rb', line 24

def n_runs
  @n_runs
end

#resize_functionObject

Returns the value of attribute resize_function

Returns:

  • (Object)

    the current value of resize_function



24
25
26
# File 'lib/prop_check/property/configuration.rb', line 24

def resize_function
  @resize_function
end

#verboseObject

Returns the value of attribute verbose

Returns:

  • (Object)

    the current value of verbose



24
25
26
# File 'lib/prop_check/property/configuration.rb', line 24

def verbose
  @verbose
end

Instance Method Details

#merge(other) ⇒ Object



46
47
48
# File 'lib/prop_check/property/configuration.rb', line 46

def merge(other)
  Configuration.new(**to_h.merge(other.to_h))
end