2013-03-07 21:05:49 +01:00
|
|
|
#!/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"
|
|
|
|
}
|
2013-10-03 21:42:52 +02:00
|
|
|
|
2016-08-01 02:30:29 +02:00
|
|
|
@test "prefix for system in /" {
|
2016-08-02 02:21:28 +02:00
|
|
|
mkdir -p "${BATS_TEST_DIRNAME}/libexec"
|
2016-08-03 08:29:59 +02:00
|
|
|
cat >"${BATS_TEST_DIRNAME}/libexec/rbenv-which" <<OUT
|
|
|
|
#!/bin/sh
|
|
|
|
echo /bin/ruby
|
|
|
|
OUT
|
2016-08-02 02:21:28 +02:00
|
|
|
chmod +x "${BATS_TEST_DIRNAME}/libexec/rbenv-which"
|
2016-08-01 02:30:29 +02:00
|
|
|
RBENV_VERSION="system" run rbenv-prefix
|
|
|
|
assert_success "/"
|
2016-08-02 02:21:28 +02:00
|
|
|
rm -f "${BATS_TEST_DIRNAME}/libexec/rbenv-which"
|
2016-08-01 02:30:29 +02:00
|
|
|
}
|
|
|
|
|
2013-10-03 21:42:52 +02:00
|
|
|
@test "prefix for invalid system" {
|
2014-01-02 22:30:21 +01:00
|
|
|
PATH="$(path_without ruby)" run rbenv-prefix system
|
2018-07-13 18:48:06 +02:00
|
|
|
assert_failure <<EOF
|
|
|
|
rbenv: ruby: command not found
|
|
|
|
rbenv: system version not found in PATH"
|
|
|
|
EOF
|
2013-10-03 21:42:52 +02:00
|
|
|
}
|