mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-29 12:32:52 -05:00
54 lines
1.1 KiB
Text
54 lines
1.1 KiB
Text
|
#!/usr/bin/env bats
|
||
|
|
||
|
load test_helper
|
||
|
|
||
|
setup() {
|
||
|
mkdir -p "${RBENV_TEST_DIR}/myproject"
|
||
|
cd "${RBENV_TEST_DIR}/myproject"
|
||
|
}
|
||
|
|
||
|
@test "no version" {
|
||
|
assert [ ! -e "${PWD}/.ruby-version" ]
|
||
|
run rbenv-local
|
||
|
assert_failure "rbenv: no local version configured for this directory"
|
||
|
}
|
||
|
|
||
|
@test "local version" {
|
||
|
echo "1.2.3" > .ruby-version
|
||
|
run rbenv-local
|
||
|
assert_success "1.2.3"
|
||
|
}
|
||
|
|
||
|
@test "ignores version in parent directory" {
|
||
|
echo "1.2.3" > .ruby-version
|
||
|
mkdir -p "subdir" && cd "subdir"
|
||
|
run rbenv-local
|
||
|
assert_failure
|
||
|
}
|
||
|
|
||
|
@test "ignores RBENV_DIR" {
|
||
|
echo "1.2.3" > .ruby-version
|
||
|
mkdir -p "$HOME"
|
||
|
echo "2.0-home" > "${HOME}/.ruby-version"
|
||
|
RBENV_DIR="$HOME" run rbenv-local
|
||
|
assert_success "1.2.3"
|
||
|
}
|
||
|
|
||
|
@test "sets local version" {
|
||
|
mkdir -p "${RBENV_ROOT}/versions/1.2.3"
|
||
|
run rbenv-local 1.2.3
|
||
|
assert_success ""
|
||
|
assert [ "$(cat .ruby-version)" = "1.2.3" ]
|
||
|
}
|
||
|
|
||
|
@test "changes local version" {
|
||
|
echo "1.0-pre" > .ruby-version
|
||
|
mkdir -p "${RBENV_ROOT}/versions/1.2.3"
|
||
|
run rbenv-local
|
||
|
assert_success "1.0-pre"
|
||
|
run rbenv-local 1.2.3
|
||
|
assert_success ""
|
||
|
run rbenv-local
|
||
|
assert_success "1.2.3"
|
||
|
}
|