2013-03-07 23:55:02 -05:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
|
|
|
|
@test "prints usage help given no argument" {
|
|
|
|
run rbenv-hooks
|
|
|
|
assert_failure "Usage: rbenv hooks <command>"
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "prints list of hooks" {
|
|
|
|
path1="${RBENV_TEST_DIR}/rbenv.d"
|
|
|
|
path2="${RBENV_TEST_DIR}/etc/rbenv_hooks"
|
2015-12-29 11:01:10 -05:00
|
|
|
RBENV_HOOK_PATH="$path1"
|
|
|
|
create_hook exec "hello.bash"
|
|
|
|
create_hook exec "ahoy.bash"
|
|
|
|
create_hook exec "invalid.sh"
|
|
|
|
create_hook which "boom.bash"
|
|
|
|
RBENV_HOOK_PATH="$path2"
|
|
|
|
create_hook exec "bueno.bash"
|
2013-03-07 23:55:02 -05:00
|
|
|
|
|
|
|
RBENV_HOOK_PATH="$path1:$path2" run rbenv-hooks exec
|
2013-04-06 08:10:44 -04:00
|
|
|
assert_success
|
|
|
|
assert_output <<OUT
|
|
|
|
${RBENV_TEST_DIR}/rbenv.d/exec/ahoy.bash
|
|
|
|
${RBENV_TEST_DIR}/rbenv.d/exec/hello.bash
|
|
|
|
${RBENV_TEST_DIR}/etc/rbenv_hooks/exec/bueno.bash
|
|
|
|
OUT
|
2013-03-07 23:55:02 -05:00
|
|
|
}
|
|
|
|
|
2013-02-24 08:52:50 -05:00
|
|
|
@test "supports hook paths with spaces" {
|
|
|
|
path1="${RBENV_TEST_DIR}/my hooks/rbenv.d"
|
|
|
|
path2="${RBENV_TEST_DIR}/etc/rbenv hooks"
|
2015-12-29 11:01:10 -05:00
|
|
|
RBENV_HOOK_PATH="$path1"
|
|
|
|
create_hook exec "hello.bash"
|
|
|
|
RBENV_HOOK_PATH="$path2"
|
|
|
|
create_hook exec "ahoy.bash"
|
2013-02-24 08:52:50 -05:00
|
|
|
|
|
|
|
RBENV_HOOK_PATH="$path1:$path2" run rbenv-hooks exec
|
2013-04-06 08:10:44 -04:00
|
|
|
assert_success
|
|
|
|
assert_output <<OUT
|
|
|
|
${RBENV_TEST_DIR}/my hooks/rbenv.d/exec/hello.bash
|
|
|
|
${RBENV_TEST_DIR}/etc/rbenv hooks/exec/ahoy.bash
|
|
|
|
OUT
|
2013-02-24 08:52:50 -05:00
|
|
|
}
|
|
|
|
|
2022-09-22 05:34:02 -04:00
|
|
|
@test "does not canonicalize paths" {
|
2015-12-29 11:01:10 -05:00
|
|
|
RBENV_HOOK_PATH="${RBENV_TEST_DIR}/rbenv.d"
|
|
|
|
create_hook exec "hello.bash"
|
2013-03-07 23:55:02 -05:00
|
|
|
mkdir -p "$HOME"
|
|
|
|
|
|
|
|
RBENV_HOOK_PATH="${HOME}/../rbenv.d" run rbenv-hooks exec
|
2022-09-22 05:34:02 -04:00
|
|
|
assert_success "${RBENV_TEST_DIR}/home/../rbenv.d/exec/hello.bash"
|
2013-03-07 23:55:02 -05:00
|
|
|
}
|
2013-03-08 14:35:46 -05:00
|
|
|
|
2022-09-22 05:34:02 -04:00
|
|
|
@test "does not resolve symlinks" {
|
2013-03-08 14:35:46 -05:00
|
|
|
path="${RBENV_TEST_DIR}/rbenv.d"
|
|
|
|
mkdir -p "${path}/exec"
|
|
|
|
mkdir -p "$HOME"
|
|
|
|
touch "${HOME}/hola.bash"
|
|
|
|
ln -s "../../home/hola.bash" "${path}/exec/hello.bash"
|
2015-10-27 15:50:14 -04:00
|
|
|
touch "${path}/exec/bright.sh"
|
|
|
|
ln -s "bright.sh" "${path}/exec/world.bash"
|
2013-03-08 14:35:46 -05:00
|
|
|
|
|
|
|
RBENV_HOOK_PATH="$path" run rbenv-hooks exec
|
2015-10-27 15:50:14 -04:00
|
|
|
assert_success
|
|
|
|
assert_output <<OUT
|
2022-09-22 05:34:02 -04:00
|
|
|
${RBENV_TEST_DIR}/rbenv.d/exec/hello.bash
|
|
|
|
${RBENV_TEST_DIR}/rbenv.d/exec/world.bash
|
2015-10-27 15:50:14 -04:00
|
|
|
OUT
|
2013-03-08 14:35:46 -05:00
|
|
|
}
|