Sha256: 01c86ee59af6e873a000c5391394f232a4cf9691b864b88609a3b54cc7aeedf1

Contents?: true

Size: 697 Bytes

Versions: 1

Compression:

Stored size: 697 Bytes

Contents

module Pact
  module Matchers
    class Difference

      attr_reader :expected, :actual

      def initialize expected, actual
        @expected = expected
        @actual = actual
      end

      def any?
        true
      end

      def to_hash
        if Regexp === expected
          {:EXPECTED_TO_MATCH => expected.inspect, :ACTUAL => actual}
        else
          {:EXPECTED => expected, :ACTUAL => actual}
        end
      end

      def to_json options = {}
        to_hash.to_json(options)
      end

      def to_s
        to_hash.to_s
      end

      def == other
        other.is_a?(Difference) && other.expected == expected && other.actual == actual
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pact-1.1.0.rc2 lib/pact/matchers/difference.rb