2013-03-20 08:43:57 -04:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
|
|
|
|
@test "creates shims and versions directories" {
|
|
|
|
assert [ ! -d "${RBENV_ROOT}/shims" ]
|
|
|
|
assert [ ! -d "${RBENV_ROOT}/versions" ]
|
|
|
|
run rbenv-init -
|
|
|
|
assert_success
|
|
|
|
assert [ -d "${RBENV_ROOT}/shims" ]
|
|
|
|
assert [ -d "${RBENV_ROOT}/versions" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "auto rehash" {
|
|
|
|
run rbenv-init -
|
|
|
|
assert_success
|
|
|
|
assert_line "rbenv rehash 2>/dev/null"
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "setup shell completions" {
|
|
|
|
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
2013-09-28 12:43:39 -04:00
|
|
|
run rbenv-init - bash
|
2013-03-20 08:43:57 -04:00
|
|
|
assert_success
|
2013-10-03 10:12:24 -04:00
|
|
|
assert_line "source '${root}/libexec/../completions/rbenv.bash'"
|
2013-03-20 08:43:57 -04:00
|
|
|
}
|
|
|
|
|
2013-09-28 12:43:39 -04:00
|
|
|
@test "detect parent shell" {
|
|
|
|
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
|
|
|
SHELL=/bin/false run rbenv-init -
|
|
|
|
assert_success
|
|
|
|
assert_line "export RBENV_SHELL=bash"
|
|
|
|
}
|
|
|
|
|
2013-08-15 10:01:13 -04:00
|
|
|
@test "setup shell completions (fish)" {
|
|
|
|
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
2013-09-28 12:43:39 -04:00
|
|
|
run rbenv-init - fish
|
2013-08-15 10:01:13 -04:00
|
|
|
assert_success
|
2013-09-28 09:04:24 -04:00
|
|
|
assert_line ". '${root}/libexec/../completions/rbenv.fish'"
|
2013-08-15 10:01:13 -04:00
|
|
|
}
|
|
|
|
|
2013-12-06 10:45:22 -05:00
|
|
|
@test "fish instructions" {
|
|
|
|
run rbenv-init fish
|
|
|
|
assert [ "$status" -eq 1 ]
|
|
|
|
assert_line 'status --is-interactive; and . (rbenv init -|psub)'
|
|
|
|
}
|
|
|
|
|
2013-03-20 08:43:57 -04:00
|
|
|
@test "option to skip rehash" {
|
|
|
|
run rbenv-init - --no-rehash
|
|
|
|
assert_success
|
|
|
|
refute_line "rbenv rehash 2>/dev/null"
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "adds shims to PATH" {
|
2014-01-02 16:17:38 -05:00
|
|
|
export PATH="${BATS_TEST_DIRNAME}/../libexec:/usr/bin:/bin:/usr/local/bin"
|
2013-09-28 12:43:39 -04:00
|
|
|
run rbenv-init - bash
|
2013-03-20 08:43:57 -04:00
|
|
|
assert_success
|
|
|
|
assert_line 0 'export PATH="'${RBENV_ROOT}'/shims:${PATH}"'
|
|
|
|
}
|
|
|
|
|
2013-08-15 10:01:13 -04:00
|
|
|
@test "adds shims to PATH (fish)" {
|
2014-01-02 16:17:38 -05:00
|
|
|
export PATH="${BATS_TEST_DIRNAME}/../libexec:/usr/bin:/bin:/usr/local/bin"
|
2013-09-28 12:43:39 -04:00
|
|
|
run rbenv-init - fish
|
2013-08-15 10:01:13 -04:00
|
|
|
assert_success
|
2013-09-28 09:04:24 -04:00
|
|
|
assert_line 0 "setenv PATH '${RBENV_ROOT}/shims' \$PATH"
|
2013-08-15 10:01:13 -04:00
|
|
|
}
|
|
|
|
|
2013-03-20 08:43:57 -04:00
|
|
|
@test "doesn't add shims to PATH more than once" {
|
|
|
|
export PATH="${RBENV_ROOT}/shims:$PATH"
|
2013-09-28 12:43:39 -04:00
|
|
|
run rbenv-init - bash
|
2013-03-20 08:43:57 -04:00
|
|
|
assert_success
|
|
|
|
refute_line 'export PATH="'${RBENV_ROOT}'/shims:${PATH}"'
|
|
|
|
}
|
2013-08-15 10:01:13 -04:00
|
|
|
|
|
|
|
@test "doesn't add shims to PATH more than once (fish)" {
|
|
|
|
export PATH="${RBENV_ROOT}/shims:$PATH"
|
2013-09-28 12:43:39 -04:00
|
|
|
run rbenv-init - fish
|
2013-08-15 10:01:13 -04:00
|
|
|
assert_success
|
|
|
|
refute_line 'setenv PATH "'${RBENV_ROOT}'/shims" $PATH ;'
|
|
|
|
}
|