-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
assert_contains function #10
Comments
The beginning of code block should have read: assert_contains() { |
I think I would usually just pair |
First of all, great project Robert, I was very happy to come across this. Regarding this issue though, just an outsider's take on this is I think the trade off is where do you want the complexity - either in the tests written to use this framework, or in the underlying framework implementation. I understand the desire to keep the assert API simple, but the fact I went searching for this functionality is probably an indication that The downside with keeping it too simple is that people like me who will tire of writing: too many times instead of:
will have to write their own On one hand this is probably exactly what should happen, everyone can write their own scripts separate to |
As a follow-up I've created a Pull Request (#13) contributing this functionality as suggested above (in new optional assert-extras.sh). Alternatively it is available in my fork: https://github.com/dansoton/assert.sh/tree/assert-extras |
Hi Robert.
Here's the assert_contains() function I wrote for regex matching.
Usage is: assert_contains "str" "regex" [0|1], where 0=expected match, 1=nomatch
assert_contains() {
# assert_contains [expected](%28 tests_ran++ %29) || :
[[ -n "$DISCOVERONLY" ]] && return || true
str=${1:-}
regex=${2:-}
expected=${3:-0}
}
The text was updated successfully, but these errors were encountered: