mirror of
https://github.com/rbenv/ruby-build.git
synced 2025-01-01 14:44:48 +01:00
21494ba359
Bats doesn't support both suite-wide setup (in helper) *and* file-wide
setup. Which means the existance of any file-level setup() function
overwrites any setup() function from test_helper. This can be confusing,
and (IMO) easier to simply avoid the overwriting and remove any
_implied_ suite-wide setup function from test_helper.
This turns out to not be so bad for the recently added setup function,
because the only test files that actually need aria2c removed from PATH
are those that actually invoke curl. These can be found because they are
the only test files that stub curl; half of which already had
file-specific setup() functions. So the only ones which need a
file-local setup() function added were: checksum.bats and mirror.bats
Along these lines, rbenv.bats and hooks.bats were removing aria2c from
PATH but don't actually need to. (curl isn't stubbed in these tests so
the existance of aria2c wouldn't affect the tests)
Lastly, fixed a tab/spaces whitespace mixup that was introduced by:
750c086d11
56 lines
1.1 KiB
Bash
56 lines
1.1 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load test_helper
|
|
|
|
setup() {
|
|
export RBENV_ROOT="${TMP}/rbenv"
|
|
export HOOK_PATH="${TMP}/i has hooks"
|
|
mkdir -p "$HOOK_PATH"
|
|
}
|
|
|
|
@test "rbenv-install hooks" {
|
|
cat > "${HOOK_PATH}/install.bash" <<OUT
|
|
before_install 'echo before: \$PREFIX'
|
|
after_install 'echo after: \$STATUS'
|
|
OUT
|
|
stub rbenv-hooks "install : echo '$HOOK_PATH'/install.bash"
|
|
stub rbenv-rehash "echo rehashed"
|
|
|
|
definition="${TMP}/2.0.0"
|
|
cat > "$definition" <<<"echo ruby-build"
|
|
run rbenv-install "$definition"
|
|
|
|
assert_success
|
|
assert_output <<-OUT
|
|
before: ${RBENV_ROOT}/versions/2.0.0
|
|
ruby-build
|
|
after: 0
|
|
rehashed
|
|
OUT
|
|
}
|
|
|
|
@test "rbenv-uninstall hooks" {
|
|
cat > "${HOOK_PATH}/uninstall.bash" <<OUT
|
|
before_uninstall 'echo before: \$PREFIX'
|
|
after_uninstall 'echo after.'
|
|
rm() {
|
|
echo "rm \$@"
|
|
command rm "\$@"
|
|
}
|
|
OUT
|
|
stub rbenv-hooks "uninstall : echo '$HOOK_PATH'/uninstall.bash"
|
|
stub rbenv-rehash "echo rehashed"
|
|
|
|
mkdir -p "${RBENV_ROOT}/versions/2.0.0"
|
|
run rbenv-uninstall -f 2.0.0
|
|
|
|
assert_success
|
|
assert_output <<-OUT
|
|
before: ${RBENV_ROOT}/versions/2.0.0
|
|
rm -rf ${RBENV_ROOT}/versions/2.0.0
|
|
rehashed
|
|
after.
|
|
OUT
|
|
|
|
refute [ -d "${RBENV_ROOT}/versions/2.0.0" ]
|
|
}
|