2008-06-18 02:57:57 -04:00
|
|
|
module Spec
|
|
|
|
|
module Matchers
|
|
|
|
|
|
|
|
|
|
class Eql #:nodoc:
|
|
|
|
|
def initialize(expected)
|
|
|
|
|
@expected = expected
|
|
|
|
|
end
|
|
|
|
|
|
2008-11-29 12:00:06 -05:00
|
|
|
def matches?(given)
|
|
|
|
|
@given = given
|
|
|
|
|
@given.eql?(@expected)
|
2008-06-18 02:57:57 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def failure_message
|
2008-11-29 12:00:06 -05:00
|
|
|
return "expected #{@expected.inspect}, got #{@given.inspect} (using .eql?)", @expected, @given
|
2008-06-18 02:57:57 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def negative_failure_message
|
2008-11-29 12:00:06 -05:00
|
|
|
return "expected #{@given.inspect} not to equal #{@expected.inspect} (using .eql?)", @expected, @given
|
2008-06-18 02:57:57 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def description
|
|
|
|
|
"eql #{@expected.inspect}"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# :call-seq:
|
|
|
|
|
# should eql(expected)
|
|
|
|
|
# should_not eql(expected)
|
|
|
|
|
#
|
2008-11-29 12:00:06 -05:00
|
|
|
# Passes if given and expected are of equal value, but not necessarily the same object.
|
2008-06-18 02:57:57 -04:00
|
|
|
#
|
|
|
|
|
# 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
|