Skip to content

Commit

Permalink
Allow "nonexistent version" test to work without brew
Browse files Browse the repository at this point in the history
Currently, this test fails if Homebrew isn't present as it expects a
Homebrew-specific output. This commit varies the expected output based
on whether Homebrew is installed.

This patch was originally created for the Debian package for ruby-build:
https://salsa.debian.org/ruby-team/ruby-build/-/blob/607093e5198cc75ffa8e9a3b551843be5f2f6d93/debian/patches/0001-Fix-nonexistent-version-test-to-work-regardless-of-e.patch
  • Loading branch information
piperswe committed Aug 14, 2024
1 parent d22fa95 commit ae2c92b
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions test/rbenv.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit ae2c92b

Please sign in to comment.