mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-14 20:39:55 -05:00
806f3f6ae2
This suppressed any output when using RBENV_DEBUG=1 and does not really hurt to have in the unlikely case that it should fail; you would get two error messages now: rbenv: ruby: command not found rbenv: system version not found in PATH
45 lines
1.1 KiB
Bash
45 lines
1.1 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load test_helper
|
|
|
|
@test "prefix" {
|
|
mkdir -p "${RBENV_TEST_DIR}/myproject"
|
|
cd "${RBENV_TEST_DIR}/myproject"
|
|
echo "1.2.3" > .ruby-version
|
|
mkdir -p "${RBENV_ROOT}/versions/1.2.3"
|
|
run rbenv-prefix
|
|
assert_success "${RBENV_ROOT}/versions/1.2.3"
|
|
}
|
|
|
|
@test "prefix for invalid version" {
|
|
RBENV_VERSION="1.2.3" run rbenv-prefix
|
|
assert_failure "rbenv: version \`1.2.3' not installed"
|
|
}
|
|
|
|
@test "prefix for system" {
|
|
mkdir -p "${RBENV_TEST_DIR}/bin"
|
|
touch "${RBENV_TEST_DIR}/bin/ruby"
|
|
chmod +x "${RBENV_TEST_DIR}/bin/ruby"
|
|
RBENV_VERSION="system" run rbenv-prefix
|
|
assert_success "$RBENV_TEST_DIR"
|
|
}
|
|
|
|
@test "prefix for system in /" {
|
|
mkdir -p "${BATS_TEST_DIRNAME}/libexec"
|
|
cat >"${BATS_TEST_DIRNAME}/libexec/rbenv-which" <<OUT
|
|
#!/bin/sh
|
|
echo /bin/ruby
|
|
OUT
|
|
chmod +x "${BATS_TEST_DIRNAME}/libexec/rbenv-which"
|
|
RBENV_VERSION="system" run rbenv-prefix
|
|
assert_success "/"
|
|
rm -f "${BATS_TEST_DIRNAME}/libexec/rbenv-which"
|
|
}
|
|
|
|
@test "prefix for invalid system" {
|
|
PATH="$(path_without ruby)" run rbenv-prefix system
|
|
assert_failure <<EOF
|
|
rbenv: ruby: command not found
|
|
rbenv: system version not found in PATH"
|
|
EOF
|
|
}
|