Class: Spec::Matchers::Match

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

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ Match

Returns a new instance of Match.



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

def initialize(expected)
  @expected = expected
end

Instance Method Details

#descriptionObject



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

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

#failure_message_for_shouldObject



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

def failure_message_for_should
  return "expected #{@actual.inspect} to match #{@expected.inspect}", @expected, @actual
end

#failure_message_for_should_notObject



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

def failure_message_for_should_not
  return "expected #{@actual.inspect} not to match #{@expected.inspect}", @expected, @actual
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


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

def matches?(actual)
  @actual = actual
  actual =~ @expected
end