Class: Crspec::Matchers::MatchMatcher

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



413
414
415
# File 'lib/crspec/matchers.rb', line 413

def failure_message
  "Expected #{@actual.inspect} to match #{@expected.inspect}"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


404
405
406
407
408
409
410
411
# File 'lib/crspec/matchers.rb', line 404

def matches?(actual)
  @actual = actual
  case @expected
  when Regexp then @expected.match?(actual.to_s)
  when String then actual.is_a?(Regexp) ? actual.match?(@expected) : actual == @expected
  else values_match?(@expected, actual)
  end
end