Skip to content

Commit 117162a

Browse files
committed
Create (and use) assert_contains
1 parent 05c4a75 commit 117162a

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

test/helpers.bash

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ refute_exists() {
66
assert [ ! -e "$1" ]
77
}
88

9+
assert_contains() {
10+
local item
11+
local items=(${@:2})
12+
for item in "${items[@]}"; do
13+
if [[ "$item" == "$1" ]]; then
14+
return 0
15+
fi
16+
done
17+
18+
fail "$1 not found in: ${items[@]}"
19+
}
20+
921
setupNotesEnv() {
1022
export NOTES_DIRECTORY="$(mktemp -d)"
1123
export NOTES_HOME="$(mktemp -d)"

test/test-bash-completion.bats

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ teardown() {
1717
@test "Should list all commands" {
1818
touch $NOTES_DIRECTORY/note1.md
1919
_notes_complete_commands ""
20-
assert_equal "${COMPREPLY[0]}" 'new'
21-
assert_equal "${COMPREPLY[1]}" 'find'
22-
assert_equal "${COMPREPLY[2]}" 'grep'
23-
assert_equal "${COMPREPLY[3]}" 'open'
20+
assert_contains "new" ${COMPREPLY[@]}
21+
assert_contains "find" ${COMPREPLY[@]}
22+
assert_contains "grep" ${COMPREPLY[@]}
23+
assert_contains "open" ${COMPREPLY[@]}
2424
}
2525

2626
@test "Should show matching note when found" {

0 commit comments

Comments
 (0)