Sha256: a041689bcdd2a9d6379788a0f3d1c1d2ea9ba7c18a61123d94f837140c45f6a8

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

module Spec
  module Matchers

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

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

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

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

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

    # :call-seq:
    #   should equal(expected)
    #   should_not equal(expected)
    #
    # Passes if actual and expected are the same object (object identity).
    #
    # See http://www.ruby-doc.org/core/classes/Object.html#M001057 for more information about equality in Ruby.
    #
    # == Examples
    #
    #   5.should equal(5) #Fixnums are equal
    #   "5".should_not equal("5") #Strings that look the same are not the same object
    def equal(expected)
      Matchers::Equal.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/equal.rb
picolena-0.1.7 rails_plugins/rspec/lib/spec/matchers/equal.rb
picolena-0.1.8 rails_plugins/rspec/lib/spec/matchers/equal.rb