Class: Smartest::MatchMatcher
- Inherits:
-
Object
- Object
- Smartest::MatchMatcher
- Defined in:
- lib/smartest/matchers.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(regexp) ⇒ MatchMatcher
constructor
A new instance of MatchMatcher.
- #matches?(actual) ⇒ Boolean
- #negated_failure_message ⇒ Object
Constructor Details
#initialize(regexp) ⇒ MatchMatcher
Returns a new instance of MatchMatcher.
226 227 228 |
# File 'lib/smartest/matchers.rb', line 226 def initialize(regexp) @regexp = regexp end |
Instance Method Details
#description ⇒ Object
245 246 247 |
# File 'lib/smartest/matchers.rb', line 245 def description "match #{@regexp.inspect}" end |
#failure_message ⇒ Object
237 238 239 |
# File 'lib/smartest/matchers.rb', line 237 def "expected #{@actual.inspect} to match #{@regexp.inspect}" end |
#matches?(actual) ⇒ Boolean
230 231 232 233 234 235 |
# File 'lib/smartest/matchers.rb', line 230 def matches?(actual) @actual = actual @regexp.match?(actual) rescue NoMethodError, TypeError false end |
#negated_failure_message ⇒ Object
241 242 243 |
# File 'lib/smartest/matchers.rb', line 241 def "expected #{@actual.inspect} not to match #{@regexp.inspect}" end |