2013-04-01 10:19:21 -04:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
|
|
|
|
create_command() {
|
|
|
|
bin="${RBENV_TEST_DIR}/bin"
|
|
|
|
mkdir -p "$bin"
|
|
|
|
echo "$2" > "${bin}/$1"
|
|
|
|
chmod +x "${bin}/$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "command with no completion support" {
|
|
|
|
create_command "rbenv-hello" "#!$BASH
|
|
|
|
echo hello"
|
|
|
|
run rbenv-completions hello
|
2015-11-17 15:01:33 -05:00
|
|
|
assert_success "--help"
|
2013-04-01 10:19:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "command with completion support" {
|
|
|
|
create_command "rbenv-hello" "#!$BASH
|
2014-01-02 16:33:54 -05:00
|
|
|
# Provide rbenv completions
|
2013-04-01 10:19:21 -04:00
|
|
|
if [[ \$1 = --complete ]]; then
|
|
|
|
echo hello
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi"
|
|
|
|
run rbenv-completions hello
|
2015-11-17 15:01:33 -05:00
|
|
|
assert_success
|
|
|
|
assert_output <<OUT
|
|
|
|
--help
|
|
|
|
hello
|
|
|
|
OUT
|
2013-04-01 10:19:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "forwards extra arguments" {
|
|
|
|
create_command "rbenv-hello" "#!$BASH
|
|
|
|
# provide rbenv completions
|
|
|
|
if [[ \$1 = --complete ]]; then
|
|
|
|
shift 1
|
2013-04-01 19:35:58 -04:00
|
|
|
for arg; do echo \$arg; done
|
2013-04-01 10:19:21 -04:00
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi"
|
|
|
|
run rbenv-completions hello happy world
|
2013-04-06 08:10:44 -04:00
|
|
|
assert_success
|
|
|
|
assert_output <<OUT
|
2015-11-17 15:01:33 -05:00
|
|
|
--help
|
2013-04-06 08:10:44 -04:00
|
|
|
happy
|
|
|
|
world
|
|
|
|
OUT
|
2013-04-01 10:19:21 -04:00
|
|
|
}
|