pyenv/test/shell.bats

92 lines
2.1 KiB
Text
Raw Normal View History

2013-03-07 15:05:49 -05:00
#!/usr/bin/env bats
load test_helper
2017-12-06 20:29:48 -05:00
@test "shell integration disabled" {
run rbenv shell
assert_failure "rbenv: shell integration not enabled. Run \`rbenv init' for instructions."
}
@test "shell integration enabled" {
eval "$(rbenv init -)"
run rbenv shell
assert_success "rbenv: no shell-specific version configured"
}
2013-03-07 15:05:49 -05:00
@test "no shell version" {
mkdir -p "${RBENV_TEST_DIR}/myproject"
cd "${RBENV_TEST_DIR}/myproject"
echo "1.2.3" > .ruby-version
RBENV_VERSION="" run rbenv-sh-shell
assert_failure "rbenv: no shell-specific version configured"
}
@test "shell version" {
RBENV_SHELL=bash RBENV_VERSION="1.2.3" run rbenv-sh-shell
2013-08-15 10:01:13 -04:00
assert_success 'echo "$RBENV_VERSION"'
}
@test "shell version (fish)" {
RBENV_SHELL=fish RBENV_VERSION="1.2.3" run rbenv-sh-shell
2013-03-07 15:05:49 -05:00
assert_success 'echo "$RBENV_VERSION"'
}
@test "shell revert" {
RBENV_SHELL=bash run rbenv-sh-shell -
assert_success
assert_line 0 'if [ -n "${RBENV_VERSION_OLD+x}" ]; then'
}
@test "shell revert (fish)" {
RBENV_SHELL=fish run rbenv-sh-shell -
assert_success
assert_line 0 'if set -q RBENV_VERSION_OLD'
}
2013-03-07 15:05:49 -05:00
@test "shell unset" {
RBENV_SHELL=bash run rbenv-sh-shell --unset
assert_success
assert_output <<OUT
2020-04-23 01:14:56 -04:00
RBENV_VERSION_OLD="\${RBENV_VERSION-}"
unset RBENV_VERSION
OUT
2013-03-07 15:05:49 -05:00
}
2013-08-15 10:01:13 -04:00
@test "shell unset (fish)" {
RBENV_SHELL=fish run rbenv-sh-shell --unset
assert_success
assert_output <<OUT
set -gu RBENV_VERSION_OLD "\$RBENV_VERSION"
set -e RBENV_VERSION
OUT
2013-08-15 10:01:13 -04:00
}
2013-03-07 15:05:49 -05:00
@test "shell change invalid version" {
run rbenv-sh-shell 1.2.3
assert_failure
assert_output <<SH
rbenv: version \`1.2.3' not installed
2013-08-15 10:01:13 -04:00
false
SH
2013-03-07 15:05:49 -05:00
}
@test "shell change version" {
mkdir -p "${RBENV_ROOT}/versions/1.2.3"
RBENV_SHELL=bash run rbenv-sh-shell 1.2.3
assert_success
assert_output <<OUT
2020-04-23 01:14:56 -04:00
RBENV_VERSION_OLD="\${RBENV_VERSION-}"
export RBENV_VERSION="1.2.3"
OUT
}
2013-08-15 10:01:13 -04:00
@test "shell change version (fish)" {
mkdir -p "${RBENV_ROOT}/versions/1.2.3"
RBENV_SHELL=fish run rbenv-sh-shell 1.2.3
assert_success
assert_output <<OUT
set -gu RBENV_VERSION_OLD "\$RBENV_VERSION"
set -gx RBENV_VERSION "1.2.3"
OUT
2013-08-15 10:01:13 -04:00
}