Sha256: 4064789dcaee33f029896ec8bbd4051aa567362bb1946ee06d5705d87d861557
Contents?: true
Size: 1.29 KB
Versions: 4
Compression:
Stored size: 1.29 KB
Contents
require_relative '../gen' require_relative '../ext_core' module Gen module Test LOWER_BOUND = ENV.fetch('TEST_LOWER_BOUND', 10).to_i UPPER_BOUND = ENV.fetch('TEST_UPPER_BOUND', 20).to_i def self.included(base) base.include(Gen) end def for_all(*generators) for_n([LOWER_BOUND, UPPER_BOUND], *generators, &Proc.new) end def for_any(*generators) for_n(1, *generators, &Proc.new) end alias for_one for_any def for_n(n, *generators) if block_given? n = Faker::Number.between(n.first, n.last) if n.respond_to?(:first) and n.respond_to?(:last) n.times do yield(*generators.map(&Gen.method(:generate))) end else raise 'A block is expected with a property definition' end end def for_each(*collections) unless collections.empty? size = collections.first.size raise "All collections must be the same size" unless collections.all? { |c| c.size == size } zipped = collections.first.zip(*collections.drop(1)) if block_given? zipped.each do |generators| yield(*generators.map { |g| Gen.generate(g) }) end else raise 'A block is expected with a property definition' end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
gen-test-0.1.3 | lib/gen/test.rb |
gen-test-0.1.2 | lib/gen/test.rb |
gen-test-0.1.1 | lib/gen/test.rb |
gen-test-0.1.0 | lib/gen/test.rb |