Class: JSON::Fuzz::Generator::Keyword::Not

Inherits:
Object
  • Object
show all
Defined in:
lib/json/fuzz/generator/keyword/not.rb

Class Method Summary collapse

Class Method Details

.invalid_params(attributes) ⇒ Object



7
8
9
10
11
12
# File 'lib/json/fuzz/generator/keyword/not.rb', line 7

def invalid_params(attributes)
  not_attribute = attributes["not"]
  raise "No not keyword given: #{attributes}" unless not_attribute

  [JSON::Fuzz::Generator.default_param(not_attribute)]
end

.valid_param(attributes) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/json/fuzz/generator/keyword/not.rb', line 14

def valid_param(attributes)
  attributes = Marshal.load(Marshal.dump(attributes))
  not_attribute = attributes.delete("not")
  raise "No not keyword given: #{attributes}" unless not_attribute
  
  generated_params = JSON::Fuzz::Generator.generate(not_attribute)

  generated_params.sample
end