Class: JSON::Fuzz::Generator::Keyword::MaxItems
- Inherits:
-
Object
- Object
- JSON::Fuzz::Generator::Keyword::MaxItems
- Defined in:
- lib/json/fuzz/generator/keyword/max_items.rb
Class Method Summary collapse
Class Method Details
.invalid_params(attributes) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/json/fuzz/generator/keyword/max_items.rb', line 7 def invalid_params(attributes) attributes = Marshal.load(Marshal.dump(attributes)) max_items = attributes.delete("maxItems") raise "No maxItems keyword given: #{attributes}" unless max_items generated_params = [] invalid_param = [] (max_items + 1).times do item = JSON::Fuzz::Generator.default_param(attributes) item = "null" if item.nil? invalid_param << item end generated_params << invalid_param generated_params end |
.valid_param(attributes) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/json/fuzz/generator/keyword/max_items.rb', line 26 def valid_param(attributes) attributes = Marshal.load(Marshal.dump(attributes)) max_items = attributes.delete("maxItems") raise "No maxItems keyword given: #{attributes}" unless max_items generated_param = [] max_items.times do generated_param << JSON::Fuzz::Generator.default_param(attributes) end generated_param end |