Add help.bats with tests for the `help` subcommand.

This commit is contained in:
William Melody 2016-01-24 21:49:33 -08:00
parent 4cf3bc0a63
commit 835d944bf9
1 changed files with 48 additions and 0 deletions

48
test/help.bats Normal file
View File

@ -0,0 +1,48 @@
#!/usr/bin/env bats
load test_helper
_HELP_HEADER="$(
cat <<HEREDOC
__ __
/ /_ ____ _____/ /______
/ __ \/ __ \/ ___/ __/ ___/
/ / / / /_/ (__ ) /_(__ )
/_/ /_/\____/____/\__/____/
HEREDOC
)"
export _HELP_HEADER
@test "\`help\` with no arguments exits with status 0." {
run "$_HOSTS" help
[ "$status" -eq 0 ]
}
@test "\`help\` with no arguments prints default help." {
run "$_HOSTS" help
[[ $(IFS=$'\n'; echo "${lines[*]:0:5}") == "$_HELP_HEADER" ]]
}
@test "\`notes -h\` prints default help." {
run "$_HOSTS" -h
[[ $(IFS=$'\n'; echo "${lines[*]:0:5}") == "$_HELP_HEADER" ]]
}
@test "\`notes --help\` prints default help." {
run "$_HOSTS" --help
[[ $(IFS=$'\n'; echo "${lines[*]:0:5}") == "$_HELP_HEADER" ]]
}
@test "\`notes help help\` prints \`help\` subcommand usage." {
run "$_HOSTS" help help
_expected="$(
cat <<HEREDOC
Usage:
hosts help [<command>]
Description:
Display help information for hosts or a specified command.
HEREDOC
)"
[[ "$output" == "$_expected" ]]
}