mirror of
https://github.com/pyenv/pyenv.git
synced 2024-12-04 21:27:08 -05:00
ed1a3a5545
Considerations: - `./libexec/rbenv` executable is the entrypoint to the program; - BASH_SOURCE might be the path to a symlink that has activated `./libexec/rbenv`; - We must resolve the symlink to learn where rbenv's libexec directory is; - It's not guaranteed that rbenv commands will always remain directly under their own "libexec" directory, since a package maintainer can change that, e.g. rbenv commands are sometimes placed into `/usr/libexec/rbenv/*`; - Resolving symlinks might fail and in that case we just assume rbenv project layout.
76 lines
1.9 KiB
Bash
76 lines
1.9 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load test_helper
|
|
|
|
@test "blank invocation" {
|
|
run rbenv
|
|
assert_failure
|
|
assert_line 0 "$(rbenv---version)"
|
|
}
|
|
|
|
@test "invalid command" {
|
|
run rbenv does-not-exist
|
|
assert_failure
|
|
assert_output "rbenv: no such command \`does-not-exist'"
|
|
}
|
|
|
|
@test "default RBENV_ROOT" {
|
|
RBENV_ROOT="" HOME=/home/mislav run rbenv root
|
|
assert_success
|
|
assert_output "/home/mislav/.rbenv"
|
|
}
|
|
|
|
@test "inherited RBENV_ROOT" {
|
|
RBENV_ROOT=/opt/rbenv run rbenv root
|
|
assert_success
|
|
assert_output "/opt/rbenv"
|
|
}
|
|
|
|
@test "default RBENV_DIR" {
|
|
run rbenv echo RBENV_DIR
|
|
assert_output "$(pwd)"
|
|
}
|
|
|
|
@test "inherited RBENV_DIR" {
|
|
dir="${BATS_TMPDIR}/myproject"
|
|
mkdir -p "$dir"
|
|
RBENV_DIR="$dir" run rbenv echo RBENV_DIR
|
|
assert_output "$dir"
|
|
}
|
|
|
|
@test "invalid RBENV_DIR" {
|
|
dir="${BATS_TMPDIR}/does-not-exist"
|
|
assert [ ! -d "$dir" ]
|
|
RBENV_DIR="$dir" run rbenv echo RBENV_DIR
|
|
assert_failure
|
|
assert_output "rbenv: cannot change working directory to \`$dir'"
|
|
}
|
|
|
|
@test "adds its own libexec to PATH" {
|
|
run rbenv echo "PATH"
|
|
assert_success "${BATS_TEST_DIRNAME}/../libexec:$PATH"
|
|
}
|
|
|
|
@test "adds plugin bin dirs to PATH" {
|
|
mkdir -p "$RBENV_ROOT"/plugins/ruby-build/bin
|
|
mkdir -p "$RBENV_ROOT"/plugins/rbenv-each/bin
|
|
run rbenv echo -F: "PATH"
|
|
assert_success
|
|
assert_line 0 "${BATS_TEST_DIRNAME}/../libexec"
|
|
assert_line 1 "${RBENV_ROOT}/plugins/ruby-build/bin"
|
|
assert_line 2 "${RBENV_ROOT}/plugins/rbenv-each/bin"
|
|
}
|
|
|
|
@test "RBENV_HOOK_PATH preserves value from environment" {
|
|
RBENV_HOOK_PATH=/my/hook/path:/other/hooks run rbenv echo -F: "RBENV_HOOK_PATH"
|
|
assert_success
|
|
assert_line 0 "/my/hook/path"
|
|
assert_line 1 "/other/hooks"
|
|
assert_line 2 "${RBENV_ROOT}/rbenv.d"
|
|
}
|
|
|
|
@test "RBENV_HOOK_PATH includes rbenv built-in plugins" {
|
|
unset RBENV_HOOK_PATH
|
|
run rbenv echo "RBENV_HOOK_PATH"
|
|
assert_success "${RBENV_ROOT}/rbenv.d:${BATS_TEST_DIRNAME}/../rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d:/usr/lib/rbenv/hooks"
|
|
}
|