Class: Spec::Matchers::Match

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ Match

Returns a new instance of Match.



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

def initialize(expected)
  @expected = expected
end

Instance Method Details

#descriptionObject



23
24
25
# File 'lib/spec/matchers/match.rb', line 23

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

#failure_messageObject



15
16
17
# File 'lib/spec/matchers/match.rb', line 15

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

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


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

def matches?(actual)
  @actual = actual
  return true if actual =~ @expected
  return false
end

#negative_failure_messageObject



19
20
21
# File 'lib/spec/matchers/match.rb', line 19

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