2013-03-07 21:05:49 +01:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
|
2017-12-07 02:29:48 +01: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 21:05:49 +01: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" {
|
2013-09-28 18:43:39 +02:00
|
|
|
RBENV_SHELL=bash RBENV_VERSION="1.2.3" run rbenv-sh-shell
|
2013-08-15 16:01:13 +02:00
|
|
|
assert_success 'echo "$RBENV_VERSION"'
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "shell version (fish)" {
|
2013-09-28 18:43:39 +02:00
|
|
|
RBENV_SHELL=fish RBENV_VERSION="1.2.3" run rbenv-sh-shell
|
2013-03-07 21:05:49 +01:00
|
|
|
assert_success 'echo "$RBENV_VERSION"'
|
|
|
|
}
|
|
|
|
|
2016-11-25 20:24:16 +01:00
|
|
|
@test "shell revert" {
|
|
|
|
RBENV_SHELL=bash run rbenv-sh-shell -
|
|
|
|
assert_success
|
2016-12-19 23:21:45 +01:00
|
|
|
assert_line 0 'if [ -n "${RBENV_VERSION_OLD+x}" ]; then'
|
2016-11-25 20:24:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "shell revert (fish)" {
|
|
|
|
RBENV_SHELL=fish run rbenv-sh-shell -
|
|
|
|
assert_success
|
2016-12-19 23:21:45 +01:00
|
|
|
assert_line 0 'if set -q RBENV_VERSION_OLD'
|
2016-11-25 20:24:16 +01:00
|
|
|
}
|
|
|
|
|
2013-03-07 21:05:49 +01:00
|
|
|
@test "shell unset" {
|
2013-09-28 18:43:39 +02:00
|
|
|
RBENV_SHELL=bash run rbenv-sh-shell --unset
|
2016-11-25 20:24:16 +01:00
|
|
|
assert_success
|
2016-01-12 20:03:50 +01:00
|
|
|
assert_output <<OUT
|
2020-04-23 07:14:56 +02:00
|
|
|
RBENV_VERSION_OLD="\${RBENV_VERSION-}"
|
2016-01-12 20:03:50 +01:00
|
|
|
unset RBENV_VERSION
|
|
|
|
OUT
|
2013-03-07 21:05:49 +01:00
|
|
|
}
|
|
|
|
|
2013-08-15 16:01:13 +02:00
|
|
|
@test "shell unset (fish)" {
|
2013-09-28 18:43:39 +02:00
|
|
|
RBENV_SHELL=fish run rbenv-sh-shell --unset
|
2016-11-25 20:24:16 +01:00
|
|
|
assert_success
|
2016-01-12 20:03:50 +01:00
|
|
|
assert_output <<OUT
|
2016-12-19 23:21:45 +01:00
|
|
|
set -gu RBENV_VERSION_OLD "\$RBENV_VERSION"
|
2016-01-12 20:03:50 +01:00
|
|
|
set -e RBENV_VERSION
|
|
|
|
OUT
|
2013-08-15 16:01:13 +02:00
|
|
|
}
|
|
|
|
|
2013-03-07 21:05:49 +01:00
|
|
|
@test "shell change invalid version" {
|
|
|
|
run rbenv-sh-shell 1.2.3
|
2013-04-06 14:10:44 +02:00
|
|
|
assert_failure
|
|
|
|
assert_output <<SH
|
|
|
|
rbenv: version \`1.2.3' not installed
|
2013-08-15 16:01:13 +02:00
|
|
|
false
|
2013-04-06 14:10:44 +02:00
|
|
|
SH
|
2013-03-07 21:05:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "shell change version" {
|
|
|
|
mkdir -p "${RBENV_ROOT}/versions/1.2.3"
|
2013-09-28 18:43:39 +02:00
|
|
|
RBENV_SHELL=bash run rbenv-sh-shell 1.2.3
|
2016-11-25 20:24:16 +01:00
|
|
|
assert_success
|
2016-01-12 20:03:50 +01:00
|
|
|
assert_output <<OUT
|
2020-04-23 07:14:56 +02:00
|
|
|
RBENV_VERSION_OLD="\${RBENV_VERSION-}"
|
2016-01-12 20:03:50 +01:00
|
|
|
export RBENV_VERSION="1.2.3"
|
|
|
|
OUT
|
|
|
|
}
|
|
|
|
|
2024-04-29 14:20:21 +02:00
|
|
|
@test "shell change version (zsh)" {
|
|
|
|
mkdir -p "${RBENV_ROOT}/versions/1.2.3"
|
|
|
|
RBENV_SHELL=zsh run rbenv-sh-shell 1.2.3
|
|
|
|
assert_success
|
|
|
|
assert_output <<OUT
|
|
|
|
typeset -g RBENV_VERSION_OLD="\${RBENV_VERSION-}"
|
|
|
|
export RBENV_VERSION="1.2.3"
|
|
|
|
OUT
|
|
|
|
}
|
|
|
|
|
2013-08-15 16:01:13 +02:00
|
|
|
@test "shell change version (fish)" {
|
|
|
|
mkdir -p "${RBENV_ROOT}/versions/1.2.3"
|
2013-09-28 18:43:39 +02:00
|
|
|
RBENV_SHELL=fish run rbenv-sh-shell 1.2.3
|
2016-11-25 20:24:16 +01:00
|
|
|
assert_success
|
|
|
|
assert_output <<OUT
|
2016-12-19 23:21:45 +01:00
|
|
|
set -gu RBENV_VERSION_OLD "\$RBENV_VERSION"
|
2016-11-25 20:24:16 +01:00
|
|
|
set -gx RBENV_VERSION "1.2.3"
|
|
|
|
OUT
|
2013-08-15 16:01:13 +02:00
|
|
|
}
|