From bf39d88d11ef341d0be5a845f170699bd40678c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Sun, 19 Oct 2014 14:34:27 +0200 Subject: [PATCH] Add tests for rbenv PATH and RBENV_HOOK_PATH handling --- test/libexec/rbenv-echo | 9 ++++++++- test/rbenv.bats | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/test/libexec/rbenv-echo b/test/libexec/rbenv-echo index 0a802df..a94af7b 100755 --- a/test/libexec/rbenv-echo +++ b/test/libexec/rbenv-echo @@ -1,2 +1,9 @@ #!/usr/bin/env bash -eval "echo \$$1" +# Usage: rbenv echo [-F] VAR + +if [[ $1 == -F* ]]; then + sep="${1:2}" + echo "${!2}" | tr "${sep:-:}" $'\n' +else + echo "${!1}" +fi diff --git a/test/rbenv.bats b/test/rbenv.bats index e8a939a..e7cea6f 100644 --- a/test/rbenv.bats +++ b/test/rbenv.bats @@ -45,3 +45,26 @@ load test_helper assert_failure assert_output "rbenv: cannot change working directory to \`$dir'" } + +@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" +}