smartrics/RestFixture — Issue #9: regex matching on TEXT responses could be simpler
Author: lachelt
Created: 2012-02-03 17:57:47+00:00
State: open

I have a simple enhancement to the TextBodyTypeAdapter.

As it stands right now you have a write a full regex that matches the entire response body. But most of the time (at least for me) that is unnecessarily complicated (especially if the response contains newlines). I just want to confirm that a string is found in the response.

So I've changed the code from this:
if (!Pattern.matches(expected,actual)) {
addError("no regex match: " + expected);
}

to this:
Pattern p = Pattern.compile(expected);
Matcher m = p.matcher(actual);
if (!m.matches() && !m.find()) {
addError("no regex match: " + expected);
}

If you agree that this is generally a good thing I'm happy to check in this change... but I've never posted a change to github before, so I'm not sure of the proper procedure. If you are going to check in another enhancement soon then it would probably be simpler for you to just include this change at the same time.