Method: PropCheck::Generators.one_of

Defined in:
lib/prop_check/generators.rb

.one_of(*choices) ⇒ Object

Picks one of the given generators in choices at random uniformly every time.

Shrinks to values earlier in the list of choices.

>> Generators.one_of(Generators.constant(true), Generators.constant(false)).sample(5, size: 10, rng: Random.new(42))
=> [true, false, true, true, true]


283
284
285
286
287
# File 'lib/prop_check/generators.rb', line 283

def one_of(*choices)
  choose(choices.length).bind do |index|
    choices[index]
  end
end