class EasyJSONMatcher::ArrayGenerator
Constants
- WHITELIST
Attributes
array_validator[R]
content_opts[R]
opts[R]
Public Class Methods
new(local_opts:, global_opts:, **args)
click to toggle source
Calls superclass method
# File lib/easy_json_matcher/array_generator.rb, line 9 def initialize(local_opts:, global_opts:, **args) super(**args) @opts = extract_opts(locals: local_opts, globals: global_opts) @content_opts = [] end
Public Instance Methods
array_options_filter()
click to toggle source
# File lib/easy_json_matcher/array_generator.rb, line 27 def array_options_filter ->(opt) { WHITELIST.include?(opt) } end
elements_should(be:)
click to toggle source
# File lib/easy_json_matcher/array_generator.rb, line 19 def elements_should(be:) @content_opts = be end
extract_opts(locals:, globals:)
click to toggle source
# File lib/easy_json_matcher/array_generator.rb, line 23 def extract_opts(locals:, globals:) (globals.select(&array_options_filter) + locals).map(&override_local_values(locals: locals)) end
generate_array()
click to toggle source
# File lib/easy_json_matcher/array_generator.rb, line 15 def generate_array array_validator.new(opts: opts, verify_content_as: content_opts) end
override_local_values(locals:)
click to toggle source
# File lib/easy_json_matcher/array_generator.rb, line 31 def override_local_values(locals:) conflicts = { required: :not_required } ->(opt) { if conflicts.keys.include? opt locals.include?(conflicts[opt]) ? conflicts[opt] : opt else opt end } end