Class: Spec::Matchers::Match

Inherits:
Object
  • Object
show all
Defined in:
lib/gems/rspec-1.1.11/lib/spec/matchers/match.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(regexp) ⇒ Match

Returns a new instance of Match.



5
6
7
# File 'lib/gems/rspec-1.1.11/lib/spec/matchers/match.rb', line 5

def initialize(regexp)
  @regexp = regexp
end

Instance Method Details

#descriptionObject



23
24
25
# File 'lib/gems/rspec-1.1.11/lib/spec/matchers/match.rb', line 23

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

#failure_messageObject



15
16
17
# File 'lib/gems/rspec-1.1.11/lib/spec/matchers/match.rb', line 15

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

#matches?(given) ⇒ Boolean

Returns:

  • (Boolean)


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

def matches?(given)
  @given = given
  return true if given =~ @regexp
  return false
end

#negative_failure_messageObject



19
20
21
# File 'lib/gems/rspec-1.1.11/lib/spec/matchers/match.rb', line 19

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