Class: GovukSchemas::RandomItemGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/govuk_schemas/random_item_generator.rb

Overview

The RandomItemGenerator takes a JSON schema and outputs a random hash that is valid against said schema.

The “randomness” here is quote relative, it's particularly tailored to the GOV.UK content schemas. For example, strings are limited to a couple of hundred characters to keep the resulting items small.

Instance Method Summary collapse

Constructor Details

#initialize(schema:) ⇒ RandomItemGenerator

Returns a new instance of RandomItemGenerator


13
14
15
# File 'lib/govuk_schemas/random_item_generator.rb', line 13

def initialize(schema:)
  @schema = schema
end

Instance Method Details

#payloadObject


17
18
19
# File 'lib/govuk_schemas/random_item_generator.rb', line 17

def payload
  generate_value(@schema)
end