Class: Spec::Matchers::Eql

Inherits:
Object show all
Defined in:
lib/spec/matchers/eql.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ Eql

Returns a new instance of Eql.



4
5
6
# File 'lib/spec/matchers/eql.rb', line 4

def initialize(expected)
  @expected = expected
end

Instance Method Details

#descriptionObject



21
22
23
# File 'lib/spec/matchers/eql.rb', line 21

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

#failure_message_for_shouldObject



13
14
15
# File 'lib/spec/matchers/eql.rb', line 13

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

#failure_message_for_should_notObject



17
18
19
# File 'lib/spec/matchers/eql.rb', line 17

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

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
# File 'lib/spec/matchers/eql.rb', line 8

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