Reputation: 1413
How can I create an expectation with a regex in the string that the method is receiving? I'm using Mocha and Mintest.
I tried this but it doesn't work:
Logger.expects(:info).with(%r{/hello, world!/}).once
Upvotes: 0
Views: 747
Reputation: 1413
You should use regexp_matches
.
Your code should look like this:
Logger.expects(:info).with(regexp_matches(%r{/hello, world!/})).once
This method is documented here: #regexp_matches(regexp) ⇒ RegexpMatches.
Upvotes: 2