Class: Crspec::Matchers::BeMatcher

Inherits:
BaseMatcher show all
Defined in:
lib/crspec/matchers.rb

Instance Attribute Summary

Attributes inherited from BaseMatcher

#actual, #expected

Instance Method Summary collapse

Methods inherited from BaseMatcher

#and, #failure_message_when_negated, #initialize, #or

Constructor Details

This class inherits a constructor from Crspec::Matchers::BaseMatcher

Instance Method Details

#failure_messageObject



98
99
100
# File 'lib/crspec/matchers.rb', line 98

def failure_message
  "Expected #{@expected.inspect} (object_id: #{@expected.object_id}), got #{@actual.inspect} (object_id: #{@actual.object_id})"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


87
88
89
90
91
92
93
94
95
96
# File 'lib/crspec/matchers.rb', line 87

def matches?(actual)
  @actual = actual
  if @expected.nil? && !instance_variable_defined?(:@expected)
    true
  elsif @expected.equal?(true) || @expected.equal?(false)
    @actual == @expected
  else
    @actual.equal?(@expected)
  end
end