contains(regex:)
Creates an expectation that requires the value to be a string that contains a match for a regular expression.
Declaration
static func contains(regex: String) -> SelfParameters
- regex:
The regular expression to search for in the string.
Return Value
An expectation that searches a string value for a match for regex.
Discussion
The regular expression can match anywhere in the string, so .contains(regex: "Building") also matches “Old Building 4”. To match the whole string, anchor the regular expression with ^ and $. A value that isn’t a string doesn’t satisfy the expectation.