2013-03-07 15:05:49 -05:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
|
|
|
|
@test "blank invocation" {
|
|
|
|
run rbenv
|
|
|
|
assert_success
|
|
|
|
assert [ "${lines[0]}" = "rbenv 0.4.0" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@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"
|
|
|
|
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"
|
|
|
|
}
|