Class: Spec::Matchers::Equal

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

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ Equal

Returns a new instance of Equal.



5
6
7
# File 'lib/spec/matchers/equal.rb', line 5

def initialize(expected)
  @expected = expected
end

Instance Method Details

#descriptionObject



22
23
24
# File 'lib/spec/matchers/equal.rb', line 22

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

#failure_message_for_shouldObject



14
15
16
# File 'lib/spec/matchers/equal.rb', line 14

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

#failure_message_for_should_notObject



18
19
20
# File 'lib/spec/matchers/equal.rb', line 18

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

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
# File 'lib/spec/matchers/equal.rb', line 9

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