Sha256: 1178f4f2602b80d494f1aee6239069d8b0a056c211ad689f81ff4021c27048a3

Contents?: true

Size: 567 Bytes

Versions: 1

Compression:

Stored size: 567 Bytes

Contents

module Mocktail::Matchers
  class Includes < Base
    extend T::Sig

    def self.matcher_name
      :includes
    end

    def initialize(*expecteds)
      @expecteds = expecteds
    end

    def match?(actual)
      @expecteds.all? { |expected|
        (actual.respond_to?(:include?) && actual.include?(expected)) ||
          (actual.is_a?(Hash) && expected.is_a?(Hash) && expected.all? { |k, v| actual[k] == v })
      }
    rescue
      false
    end

    def inspect
      "#{self.class.matcher_name}(#{@expecteds.map(&:inspect).join(", ")})"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mocktail-2.0.0 lib/mocktail/matchers/includes.rb