Closed djerius closed 9 years ago
It seems that I'm mistaken about has_error
After perusing the code I see that it only supports exact substring matching and matching numbers at ends of strings.
A generic pattern match would be nice. I have errors which include keywords taken from tables, so their order in the error message are non-deterministic. I need to be able to check for strings like
a and b are excluded
b and a are excluded
and ensure that the a
and b
keywords are in the error message (else I could just look for the string are excluded
)
Here's some example code:
https://gist.github.com/djerius/7879cbd6d9ac66257e32
It allows one to write
assert.matches( "[ab] and [ab] are excluded", retval )
@djerius I think this went into v1.7.7
I'm testing code which uses the common
paradigm, where
retval
is an error message/object ifok
is false. Just as with error messages tossed via exceptions (and handled byhas_error
) it would be nice to be able to compare the result with a match rather than an exact equality, e.g.Thanks for a great testing framework! Diab