From 09b18cf6f5824be9c4fa30bca9cd9dfe6932be92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Fri, 13 Nov 2015 22:53:27 -0500 Subject: [PATCH 1/2] Add test for version-origin when version not found in `rbenv-exec` --- test/exec.bats | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/exec.bats b/test/exec.bats index ff1e248d..6c5c7880 100644 --- a/test/exec.bats +++ b/test/exec.bats @@ -20,6 +20,12 @@ create_executable() { assert_failure "rbenv: version \`2.0' is not installed (set by RBENV_VERSION environment variable)" } +@test "fails with invalid version set from file" { + echo 1.9 > .ruby-version + run rbenv-exec rspec + assert_failure "rbenv: version \`1.9' is not installed (set by $PWD/.ruby-version)" +} + @test "completes with names of executables" { export RBENV_VERSION="2.0" create_executable "ruby" "#!/bin/sh" From 3405c4d03cc4b1e63c2829e2565f7651b09bebb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Fri, 13 Nov 2015 22:57:22 -0500 Subject: [PATCH 2/2] Fix error message when command is not found for "system" version If `foo` didn't exist and `RBENV_VERSION=system rbenv which foo` was called, the error message used to be misleading: rbenv: version `system' is not installed Instead, have the error message simply say that the command was not found. Fixes #770 --- libexec/rbenv-which | 2 +- test/which.bats | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libexec/rbenv-which b/libexec/rbenv-which index 8019be21..f4d46245 100755 --- a/libexec/rbenv-which +++ b/libexec/rbenv-which @@ -51,7 +51,7 @@ done if [ -x "$RBENV_COMMAND_PATH" ]; then echo "$RBENV_COMMAND_PATH" -elif ! [ -d "${RBENV_ROOT}/versions/${RBENV_VERSION}" ]; then +elif [ "$RBENV_VERSION" != "system" ] && [ ! -d "${RBENV_ROOT}/versions/${RBENV_VERSION}" ]; then echo "rbenv: version \`$RBENV_VERSION' is not installed (set by $(rbenv-version-origin))" >&2 exit 1 else diff --git a/test/which.bats b/test/which.bats index bf10effe..25c80528 100644 --- a/test/which.bats +++ b/test/which.bats @@ -68,6 +68,12 @@ create_executable() { assert_failure "rbenv: rake: command not found" } +@test "no executable found for system version" { + export PATH="$(path_without "rake")" + RBENV_VERSION=system run rbenv-which rake + assert_failure "rbenv: rake: command not found" +} + @test "executable found in other versions" { create_executable "1.8" "ruby" create_executable "1.9" "rspec"