Module: Quick::Sampler

Defined in:
lib/quick/sampler.rb,
lib/quick/sampler/dsl.rb,
lib/quick/sampler/base.rb,
lib/quick/sampler/shrink.rb,
lib/quick/sampler/version.rb,
lib/quick/sampler/dsl/fluidiom.rb,
lib/quick/sampler/dsl/simple_values.rb,
lib/quick/sampler/shrink/refinements.rb,
lib/quick/sampler/dsl/character_class.rb,
lib/quick/sampler/dsl/simple_combinators.rb,
lib/quick/sampler/shrink/class_methods/while.rb

Overview

A façade module with the main entry point: Sampler.compile

Defined Under Namespace

Classes: Base, DSL

Constant Summary collapse

VERSION =
"0.1.5"

Class Method Summary collapse

Class Method Details

.===(obj) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Tests if obj is an instance of a known Quick Sampler sub-type.

Parameters:

  • obj (Object)

    the object to test

Returns:

  • (Boolean)

    true if the object is of a Quick Sampler sub-type



43
44
45
# File 'lib/quick/sampler.rb', line 43

def === obj
  Base === obj || DSL::Fluidiom === obj
end

.compile(description: nil, &block) ⇒ Quick::Sampler

Main entry point of Quick Sampler. Compiles a definition into a sampler. The "compilation" is only a metaphor here, since definition - which is given to compile as a block - is simply executed in the context of a fresh DSL instance (where available syntax can be found).

Examples:

Compile a sampler

chaos = Quick::Sampler.compile description: "a bit of everything" do
  one_of_weighted integer => 5,
                  boolean => 1,
                  pick_from(-10.0..10.0) => 10,
                  string(:alnum) => 15,
                  feed { Faker::Internet.email } => 3
end

Parameters:

  • description (String) (defaults to: nil)

    sampler description which will be returned by #inspect as well as #description

  • block

    sampler definition. Will be instance_evaled in the context of an anonymous instance of DSL.

Returns:



35
# File 'lib/quick/sampler.rb', line 35

delegate :compile, to: Quick::Sampler::DSL