Merge branch 'which-fixes'

This commit is contained in:
Mislav Marohnić 2015-11-14 10:42:41 +00:00
commit c30e096a54
3 changed files with 13 additions and 1 deletions

View file

@ -51,7 +51,7 @@ done
if [ -x "$RBENV_COMMAND_PATH" ]; then if [ -x "$RBENV_COMMAND_PATH" ]; then
echo "$RBENV_COMMAND_PATH" 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 echo "rbenv: version \`$RBENV_VERSION' is not installed (set by $(rbenv-version-origin))" >&2
exit 1 exit 1
else else

View file

@ -20,6 +20,12 @@ create_executable() {
assert_failure "rbenv: version \`2.0' is not installed (set by RBENV_VERSION environment variable)" 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" { @test "completes with names of executables" {
export RBENV_VERSION="2.0" export RBENV_VERSION="2.0"
create_executable "ruby" "#!/bin/sh" create_executable "ruby" "#!/bin/sh"

View file

@ -68,6 +68,12 @@ create_executable() {
assert_failure "rbenv: rake: command not found" 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" { @test "executable found in other versions" {
create_executable "1.8" "ruby" create_executable "1.8" "ruby"
create_executable "1.9" "rspec" create_executable "1.9" "rspec"