2013-03-07 21:05:49 +01:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
|
|
|
|
@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"'
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "shell unset" {
|
2013-09-28 18:43:39 +02:00
|
|
|
RBENV_SHELL=bash run rbenv-sh-shell --unset
|
2016-01-12 20:03:50 +01:00
|
|
|
assert_output <<OUT
|
|
|
|
unset OLD_RBENV_VERSION
|
|
|
|
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-01-12 20:03:50 +01:00
|
|
|
assert_output <<OUT
|
|
|
|
set -e OLD_RBENV_VERSION
|
|
|
|
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-01-12 20:03:50 +01:00
|
|
|
assert_output <<OUT
|
|
|
|
export OLD_RBENV_VERSION=""
|
|
|
|
export RBENV_VERSION="1.2.3"
|
|
|
|
OUT
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "shell change version pushes away previous OLD_RBENV_VERSION" {
|
|
|
|
mkdir -p "${RBENV_ROOT}/versions/1.2.3"
|
|
|
|
mkdir -p "${RBENV_ROOT}/versions/1.2.4"
|
|
|
|
mkdir -p "${RBENV_ROOT}/versions/1.2.5"
|
|
|
|
export OLD_RBENV_VERSION="1.2.3"
|
|
|
|
export RBENV_VERSION="1.2.4"
|
|
|
|
RBENV_SHELL=bash run rbenv-sh-shell 1.2.5
|
|
|
|
assert_output <<OUT
|
|
|
|
export OLD_RBENV_VERSION="1.2.4"
|
|
|
|
export RBENV_VERSION="1.2.5"
|
|
|
|
OUT
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "shell change version to the same version does not lose OLD_RBENV_VERSION" {
|
|
|
|
mkdir -p "${RBENV_ROOT}/versions/1.2.3"
|
|
|
|
mkdir -p "${RBENV_ROOT}/versions/1.2.4"
|
|
|
|
export OLD_RBENV_VERSION="1.2.3"
|
|
|
|
export RBENV_VERSION="1.2.4"
|
|
|
|
RBENV_SHELL=bash run rbenv-sh-shell 1.2.4
|
|
|
|
assert_output ''
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "shell change version to - swaps old and new versions" {
|
|
|
|
mkdir -p "${RBENV_ROOT}/versions/1.2.3"
|
|
|
|
mkdir -p "${RBENV_ROOT}/versions/1.2.4"
|
|
|
|
export OLD_RBENV_VERSION="1.2.3"
|
|
|
|
export RBENV_VERSION="1.2.4"
|
|
|
|
RBENV_SHELL=bash run rbenv-sh-shell -
|
|
|
|
assert_output <<OUT
|
|
|
|
export OLD_RBENV_VERSION="1.2.4"
|
|
|
|
export RBENV_VERSION="1.2.3"
|
|
|
|
OUT
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "shell change version to - with no previous is an error" {
|
|
|
|
mkdir -p "${RBENV_ROOT}/versions/1.2.3"
|
|
|
|
RBENV_SHELL=bash run rbenv-sh-shell -
|
|
|
|
assert_failure <<OUT
|
|
|
|
rbenv: OLD_RBENV_VERSION not set
|
|
|
|
OUT
|
2013-03-07 21:05:49 +01:00
|
|
|
}
|
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
|
2013-08-15 16:01:13 +02:00
|
|
|
assert_success 'setenv RBENV_VERSION "1.2.3"'
|
|
|
|
}
|