Class: Polyrun::Quick::RegexMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/polyrun/quick/matchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(pattern) ⇒ RegexMatcher

Returns a new instance of RegexMatcher.



133
134
135
# File 'lib/polyrun/quick/matchers.rb', line 133

def initialize(pattern)
  @pattern = pattern
end

Instance Method Details

#does_not_match?(actual) ⇒ Boolean

Returns:

  • (Boolean)


143
144
145
# File 'lib/polyrun/quick/matchers.rb', line 143

def does_not_match?(actual)
  !matches?(actual)
end

#failure_message(actual) ⇒ Object



147
148
149
# File 'lib/polyrun/quick/matchers.rb', line 147

def failure_message(actual)
  "expected #{actual.inspect} to match #{@pattern.inspect}"
end

#failure_message_when_negated(actual) ⇒ Object



151
152
153
# File 'lib/polyrun/quick/matchers.rb', line 151

def failure_message_when_negated(actual)
  "expected #{actual.inspect} not to match #{@pattern.inspect}"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


137
138
139
140
141
# File 'lib/polyrun/quick/matchers.rb', line 137

def matches?(actual)
  return false unless actual.respond_to?(:to_s)

  @pattern === actual.to_s
end