Class: Pact::Generator::RandomString
- Inherits:
-
Object
- Object
- Pact::Generator::RandomString
- Defined in:
- lib/pact/generator/random_string.rb
Overview
RandomString provides the random string generator which generate a random string of size length
Instance Method Summary collapse
Instance Method Details
#call(hash, _params = nil, _example_value = nil) ⇒ Object
9 10 11 12 13 |
# File 'lib/pact/generator/random_string.rb', line 9 def call(hash, _params = nil, _example_value = nil) size = hash['size'] || 20 string = rand(36**(size + 2)).to_s(36) string[0, size] end |
#can_generate?(hash) ⇒ Boolean
5 6 7 |
# File 'lib/pact/generator/random_string.rb', line 5 def can_generate?(hash) hash.key?('type') && hash['type'] == 'RandomString' end |