class RSpec::JsonExpectations::Matchers::UnorderedArrayMatcher

Attributes

array[R]

Public Class Methods

new(array) click to toggle source
# File lib/rspec/json_expectations/matchers.rb, line 80
def initialize(array)
  @array = array
end

Public Instance Methods

all?(&blk) click to toggle source
# File lib/rspec/json_expectations/matchers.rb, line 106
def all?(&blk)
  array.each_with_index.all?(&blk)
end
check_for_missing(missing, item, index, ok) click to toggle source
# File lib/rspec/json_expectations/matchers.rb, line 101
def check_for_missing(missing, item, index, ok)
  missing << { item: item, index: index } unless ok
  ok
end
match(errors, actual, prefix) click to toggle source
# File lib/rspec/json_expectations/matchers.rb, line 84
def match(errors, actual, prefix)
  missing_items = []
  errors[prefix.join("/")] = { missing: missing_items }

  all? do |expected_item, index|
    match_one(missing_items, expected_item, index, actual)
  end
end
match_one(missing, item, index, actual) click to toggle source
# File lib/rspec/json_expectations/matchers.rb, line 93
def match_one(missing, item, index, actual)
  check_for_missing(missing, item, index,
    actual.any? do |actual_item|
      JsonTraverser.traverse({}, item, actual_item, false)
    end
  )
end
unwrap_array() click to toggle source
# File lib/rspec/json_expectations/matchers.rb, line 110
def unwrap_array
  array
end