Sha256: 6e576f838f4420266e6b6aceb230df30c7ab1c34aea18a8f2073be6755081d26

Contents?: true

Size: 430 Bytes

Versions: 2

Compression:

Stored size: 430 Bytes

Contents

module Pact
  module Generator
    # RandomInt provides the random int generator which generate a random integer, with a min/max
    class RandomInt
      def can_generate?(hash)
        hash.key?('type') && hash['type'] == 'RandomInt'
      end

      def call(hash, _params = nil, _example_value = nil)
        min = hash['min'] || 0
        max = hash['max'] || 2_147_483_647
        rand(min..max)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pact-support-1.21.1 lib/pact/generator/random_int.rb
pact-support-1.21.0 lib/pact/generator/random_int.rb