Sha256: 3dad677ff774c727785ff6a5ce506391cb2b10b24f0997fc8e6a16f6e15854c6

Contents?: true

Size: 1.11 KB

Versions: 18

Compression:

Stored size: 1.11 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

18 entries across 18 versions & 3 rubygems

Version Path
puppet-0.23.0 test/lib/spec/matchers/equal.rb
puppet-0.22.4 test/lib/spec/matchers/equal.rb
puppet-0.23.2 test/lib/spec/matchers/equal.rb
puppet-0.23.1 test/lib/spec/matchers/equal.rb
riess-0.0.8 vendor/rspec-0.8.2/lib/spec/matchers/equal.rb
rspec-0.8.0 lib/spec/matchers/equal.rb
rspec-0.8.1 lib/spec/matchers/equal.rb
rspec-0.9.1 lib/spec/matchers/equal.rb
rspec-0.9.2 lib/spec/matchers/equal.rb
rspec-0.9.4 lib/spec/matchers/equal.rb
rspec-1.0.0 lib/spec/matchers/equal.rb
rspec-1.0.1 lib/spec/matchers/equal.rb
rspec-1.0.2 lib/spec/matchers/equal.rb
rspec-1.0.3 lib/spec/matchers/equal.rb
rspec-1.0.4 lib/spec/matchers/equal.rb
rspec-0.9.3 lib/spec/matchers/equal.rb
rspec-0.8.2 lib/spec/matchers/equal.rb
rspec-0.9.0 lib/spec/matchers/equal.rb