Sha256: 95e4fd7bfac034db1887bac9f806d76b30a59b492b5e79755a4793c47d4384e5

Contents?: true

Size: 1.04 KB

Versions: 9

Compression:

Stored size: 1.04 KB

Contents

module Spec
  module Matchers
    class Eql
      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)
      Eql.new(expected)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dchelimsky-rspec-1.1.99.1 lib/spec/matchers/eql.rb
dchelimsky-rspec-1.1.99.2 lib/spec/matchers/eql.rb
dchelimsky-rspec-1.1.99.3 lib/spec/matchers/eql.rb
dchelimsky-rspec-1.1.99.4 lib/spec/matchers/eql.rb
dchelimsky-rspec-1.1.99.5 lib/spec/matchers/eql.rb
dchelimsky-rspec-1.1.99.6 lib/spec/matchers/eql.rb
dchelimsky-rspec-1.1.99.7 lib/spec/matchers/eql.rb
dchelimsky-rspec-1.1.99.8 lib/spec/matchers/eql.rb
dchelimsky-rspec-1.1.99.9 lib/spec/matchers/eql.rb