Test IFS handling in version-name/version-origin hooks

This commit is contained in:
Jason Karns 2015-12-29 11:15:27 -05:00
parent 0f7a2cad8d
commit 565798d617
2 changed files with 24 additions and 0 deletions

View file

@ -31,6 +31,18 @@ setup() {
assert_success "1.9.3" assert_success "1.9.3"
} }
@test "carries original IFS within hooks" {
create_hook version-name hello.bash <<SH
hellos=(\$(printf "hello\\tugly world\\nagain"))
echo HELLO="\$(printf ":%s" "\${hellos[@]}")"
SH
export RBENV_VERSION=system
IFS=$' \t\n' run rbenv-version-name env
assert_success
assert_line "HELLO=:hello:ugly:world:again"
}
@test "RBENV_VERSION has precedence over local" { @test "RBENV_VERSION has precedence over local" {
create_version "1.8.7" create_version "1.8.7"
create_version "1.9.3" create_version "1.9.3"

View file

@ -38,6 +38,18 @@ setup() {
assert_success "plugin" assert_success "plugin"
} }
@test "carries original IFS within hooks" {
create_hook version-origin hello.bash <<SH
hellos=(\$(printf "hello\\tugly world\\nagain"))
echo HELLO="\$(printf ":%s" "\${hellos[@]}")"
SH
export RBENV_VERSION=system
IFS=$' \t\n' run rbenv-version-origin env
assert_success
assert_line "HELLO=:hello:ugly:world:again"
}
@test "doesn't inherit RBENV_VERSION_ORIGIN from environment" { @test "doesn't inherit RBENV_VERSION_ORIGIN from environment" {
RBENV_VERSION_ORIGIN=ignored run rbenv-version-origin RBENV_VERSION_ORIGIN=ignored run rbenv-version-origin
assert_success "${RBENV_ROOT}/version" assert_success "${RBENV_ROOT}/version"