Skip to content

Commit

Permalink
Allow "nonexistent version" test to work without Git repo
Browse files Browse the repository at this point in the history
Currently, this test fails if .git isn't present as it expects a
Git-specific output. This change temporarily creates a ".git"
directory during the test run to simulate the existence of a git
repository, thus keeping `rbenv install` output stable.

Co-authored-by: Mislav Marohnić <[email protected]>
  • Loading branch information
piperswe and mislav committed Jan 21, 2025
1 parent 3366b3b commit 434ce5f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/rbenv.bats
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,19 @@ OUT
}

@test "nonexistent version" {
stub_git_dir=
if [ ! -d "${BATS_TEST_DIRNAME}"/../.git ]; then
stub_git_dir="${BATS_TEST_DIRNAME}"/../.git
mkdir "$stub_git_dir"
fi

stub_repeated brew false
stub_ruby_build 'echo ERROR >&2 && exit 2' \
"--definitions : echo 1.8.7 1.9.3-p0 1.9.3-p194 2.1.2 | tr ' ' $'\\n'"

run rbenv-install 1.9.3
[ -z "$stub_git_dir" ] || rmdir "$stub_git_dir"

assert_failure
assert_output <<OUT
ERROR
Expand Down

0 comments on commit 434ce5f

Please sign in to comment.