2013-03-07 15:05:49 -05:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
|
|
|
|
@test "blank invocation" {
|
|
|
|
run rbenv
|
2015-11-18 19:52:48 -05:00
|
|
|
assert_failure
|
2015-11-14 07:21:16 -05:00
|
|
|
assert_line 0 "$(rbenv---version)"
|
2013-03-07 15:05:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@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'"
|
|
|
|
}
|
2014-10-19 08:34:27 -04:00
|
|
|
|
|
|
|
@test "adds its own libexec to PATH" {
|
|
|
|
run rbenv echo "PATH"
|
2022-09-29 09:27:17 -04:00
|
|
|
assert_success "${BATS_TEST_DIRNAME}/../libexec:$PATH"
|
2014-10-19 08:34:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@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
|
2022-09-29 09:27:17 -04:00
|
|
|
assert_line 0 "${BATS_TEST_DIRNAME}/../libexec"
|
2014-10-19 08:34:27 -04:00
|
|
|
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"
|
|
|
|
}
|
2014-10-16 10:31:51 -04:00
|
|
|
|
|
|
|
@test "RBENV_HOOK_PATH includes rbenv built-in plugins" {
|
2015-12-29 10:53:01 -05:00
|
|
|
unset RBENV_HOOK_PATH
|
2014-10-16 10:31:51 -04:00
|
|
|
run rbenv echo "RBENV_HOOK_PATH"
|
2022-09-29 09:27:17 -04:00
|
|
|
assert_success "${RBENV_ROOT}/rbenv.d:${BATS_TEST_DIRNAME}/../rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d:/usr/lib/rbenv/hooks"
|
2014-10-16 10:31:51 -04:00
|
|
|
}
|