Sha256: ec1de9b5b8c1305e1abd893580c4ac561374896423724ed98c47a72f96ea1a85

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

module Spec
  module Matchers

    class Eql #:nodoc:
      def initialize(expected)
        @expected = expected
      end

      def matches?(actual)
        @actual = actual
        @actual.eql?(@expected)
      end

      def failure_message
        return "expected #{@expected.inspect}, got #{@actual.inspect} (using .eql?)", @expected, @actual
      end

      def negative_failure_message
        return "expected #{@actual.inspect} not to equal #{@expected.inspect} (using .eql?)", @expected, @actual
      end

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

    # :call-seq:
    #   should eql(expected)
    #   should_not eql(expected)
    #
    # Passes if actual and expected are of equal value, but not necessarily the same object.
    #
    # See http://www.ruby-doc.org/core/classes/Object.html#M001057 for more information about equality in Ruby.
    #
    # == Examples
    #
    #   5.should eql(5)
    #   5.should_not eql(3)
    def eql(expected)
      Matchers::Eql.new(expected)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
picolena-0.1.6 rails_plugins/rspec/lib/spec/matchers/eql.rb
picolena-0.1.7 rails_plugins/rspec/lib/spec/matchers/eql.rb
picolena-0.1.8 rails_plugins/rspec/lib/spec/matchers/eql.rb