mirror of
https://github.com/rbenv/rbenv.git
synced 2025-01-16 19:21:03 +01:00
0f7a2cad8d
Use extracted create_hook helper in tests for: - exec - hooks - rehash - version-name - version-origin - which
44 lines
1,019 B
Bash
44 lines
1,019 B
Bash
#!/usr/bin/env bats
|
|
|
|
load test_helper
|
|
|
|
setup() {
|
|
mkdir -p "$RBENV_TEST_DIR"
|
|
cd "$RBENV_TEST_DIR"
|
|
}
|
|
|
|
@test "reports global file even if it doesn't exist" {
|
|
assert [ ! -e "${RBENV_ROOT}/version" ]
|
|
run rbenv-version-origin
|
|
assert_success "${RBENV_ROOT}/version"
|
|
}
|
|
|
|
@test "detects global file" {
|
|
mkdir -p "$RBENV_ROOT"
|
|
touch "${RBENV_ROOT}/version"
|
|
run rbenv-version-origin
|
|
assert_success "${RBENV_ROOT}/version"
|
|
}
|
|
|
|
@test "detects RBENV_VERSION" {
|
|
RBENV_VERSION=1 run rbenv-version-origin
|
|
assert_success "RBENV_VERSION environment variable"
|
|
}
|
|
|
|
@test "detects local file" {
|
|
touch .ruby-version
|
|
run rbenv-version-origin
|
|
assert_success "${PWD}/.ruby-version"
|
|
}
|
|
|
|
@test "reports from hook" {
|
|
create_hook version-origin test.bash <<<"RBENV_VERSION_ORIGIN=plugin"
|
|
|
|
RBENV_VERSION=1 run rbenv-version-origin
|
|
assert_success "plugin"
|
|
}
|
|
|
|
@test "doesn't inherit RBENV_VERSION_ORIGIN from environment" {
|
|
RBENV_VERSION_ORIGIN=ignored run rbenv-version-origin
|
|
assert_success "${RBENV_ROOT}/version"
|
|
}
|