diff --git a/scripts/fgrep b/scripts/fgrep index 6760287..b839d23 100755 --- a/scripts/fgrep +++ b/scripts/fgrep @@ -20,7 +20,7 @@ source "${mydir}"/../helper/set_variable.sh source "${mydir}"/../helper/git_query.sh function usage() { - echo -e "Usage: dotbare fgrep [-h] ... + echo -e "Usage: dotbare fgrep [-h] [-c] [-f] ... Grep words within tracked files and select to edit matches. diff --git a/tests/fgrep.bats b/tests/fgrep.bats index c0dc4e0..b1375d4 100755 --- a/tests/fgrep.bats +++ b/tests/fgrep.bats @@ -14,10 +14,32 @@ edit_lines() { bash "${BATS_TEST_DIRNAME}"/../dotbare fgrep } +full_deli() { + export PATH="${BATS_TEST_DIRNAME}:$PATH" + export EDITOR="echo" + bash "${BATS_TEST_DIRNAME}"/../dotbare fgrep --full +} + +option_deli() { + export PATH="${BATS_TEST_DIRNAME}:$PATH" + export EDITOR="echo" + bash "${BATS_TEST_DIRNAME}"/../dotbare fgrep --col 2 +} + +@test "fgrep option delimiter" { + run option_deli + [[ "${output}" =~ "--nth 2.. --header=select matches to edit" ]] +} + +@test "fgrep full delimiter" { + run full_deli + [[ "${output}" =~ "--nth 1.. --header=select matches to edit" ]] +} + @test "fgrep help" { run help [ "${status}" -eq 0 ] - [ "${lines[0]}" = "Usage: dotbare fgrep [-h] ..." ] + [ "${lines[0]}" = "Usage: dotbare fgrep [-h] [-c] [-f] ..." ] } @test "fgrep invalid option" { @@ -28,5 +50,5 @@ edit_lines() { @test "fgrep edit lines" { run edit_lines - [[ "${output}" =~ "fgrep_words" ]] + [[ "${output}" =~ "--nth 3.. --header=select matches to edit" ]] } diff --git a/tests/fzf b/tests/fzf index b027fd7..484a617 100755 --- a/tests/fzf +++ b/tests/fzf @@ -60,9 +60,6 @@ elif [[ "$*" =~ '--header=select stash to delete' ]] && [[ "$*" =~ "show -p __ - elif [[ "$*" =~ '--header=select stash to apply' ]] && [[ "$*" =~ "show -p __ --color=always" ]]; then # dotbare fstash -- "./fstash.bats" @test "fstash apply stash" echo "fstash_apply" -elif [[ "$*" =~ '--delimiter : --nth 3..' ]]; then - # dotbare fgrep -- "./fgrep.bats" @test "fgrep edit lines" - echo "fgrep_words" else echo "$@" fi