Sha256: d926583d037cd2ff0208e5b269e15b666f79685809b5d9bb48fea10b4e81269c
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 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, &block) for_n([LOWER_BOUND, UPPER_BOUND], *generators, &block) end def for_any(*generators, &block) for_n(1, *generators, &block) 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gen-test-0.2.0 | lib/gen/test.rb |