Sha256: a9f232b8507a9fc8f5d34c1d8e8f85cd65feaa95029633206aa45157d16900c1

Contents?: true

Size: 595 Bytes

Versions: 1

Compression:

Stored size: 595 Bytes

Contents

# frozen_string_literal: true

module RSpec::ResemblesJsonMatchers
  class ResemblesArrayMatcher
    include Helpers

    def self.can_match?(array)
      array.is_a? Array
    end

    def initialize(expected)
      @expected = expected
    end

    def description
      "resemble #{@expected.inspect}"
    end

    def matches?(actual)
      actual.is_a?(Array) && actual.all? do |a|
        expected_matchers.any? do |e|
          e.matches? a
        end
      end
    end

    def expected_matchers
      @expected.map { |e| matcherize(e) }
    end

    def failure_message; end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-resembles_json_matchers-0.9.1 lib/rspec/resembles_json_matchers/resembles_array_matcher.rb