From 248525742446d58f38c3ef9a5c3186fdc9d17cd9 Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Mon, 1 Aug 2016 00:30:29 +0000 Subject: [PATCH] Add a test to confirm the prefix doesn't work fine with `/bin/ruby` --- test/prefix.bats | 9 +++++++++ test/test_helper.bash | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/test/prefix.bats b/test/prefix.bats index 3fb94086..b78b8f94 100644 --- a/test/prefix.bats +++ b/test/prefix.bats @@ -24,6 +24,15 @@ load test_helper assert_success "$RBENV_TEST_DIR" } +@test "prefix for system in /" { + mkdir -p "${RBENV_TEST_DIR}/bin" + touch "${RBENV_TEST_DIR}/bin/rbenv-which" + echo "echo /bin/ruby" >"${RBENV_TEST_DIR}/bin/rbenv-which" + chmod +x "${RBENV_TEST_DIR}/bin/rbenv-which" + RBENV_VERSION="system" run rbenv-prefix + assert_success "/" +} + @test "prefix for invalid system" { PATH="$(path_without ruby)" run rbenv-prefix system assert_failure "rbenv: system version not found in PATH" diff --git a/test/test_helper.bash b/test/test_helper.bash index aef883a4..a6cbb74e 100644 --- a/test/test_helper.bash +++ b/test/test_helper.bash @@ -20,10 +20,10 @@ if [ -z "$RBENV_TEST_DIR" ]; then export RBENV_HOOK_PATH="${RBENV_ROOT}/rbenv.d" PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin - PATH="${RBENV_TEST_DIR}/bin:$PATH" PATH="${BATS_TEST_DIRNAME}/../libexec:$PATH" PATH="${BATS_TEST_DIRNAME}/libexec:$PATH" PATH="${RBENV_ROOT}/shims:$PATH" + PATH="${RBENV_TEST_DIR}/bin:$PATH" export PATH for xdg_var in `env 2>/dev/null | grep ^XDG_ | cut -d= -f1`; do unset "$xdg_var"; done