1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
From: Piper McCorkle <contact@piperswe.me>
Date: Wed, 14 Aug 2024 00:19:27 -0500
Subject: Fix "nonexistent version" test to work regardless of env
Forwarded: https://github.com/rbenv/ruby-build/pull/2432
---
test/rbenv.bats | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/test/rbenv.bats b/test/rbenv.bats
index 4496b1f..938ea12 100644
--- a/test/rbenv.bats
+++ b/test/rbenv.bats
@@ -94,7 +94,8 @@ OUT
run rbenv-install 1.9.3
assert_failure
- assert_output <<OUT
+ (
+ cat <<OUT
ERROR
The following versions contain \`1.9.3' in the name:
@@ -103,10 +104,19 @@ The following versions contain \`1.9.3' in the name:
See all available versions with \`rbenv install --list-all'.
-If the version you need is missing, try upgrading ruby-build:
-
- git -C ${BATS_TEST_DIRNAME/$HOME\//~/}/.. pull
OUT
+ here="${BATS_TEST_DIRNAME}/.."
+ echo -n "If the version you need is missing, try upgrading ruby-build"
+ if [ "$here" != "${here#$(brew --prefix 2>/dev/null)}" ]; then
+ printf ":\n\n"
+ echo " brew update && brew upgrade ruby-build"
+ elif [ -d "${here}/.git" ]; then
+ printf ":\n\n"
+ echo " git -C ${here} pull"
+ else
+ printf ".\n"
+ fi
+ ) | assert_output
unstub brew
unstub ruby-build
|