mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-07 20:31:01 -05:00
52 lines
1.1 KiB
Bash
Executable file
52 lines
1.1 KiB
Bash
Executable file
#!/usr/bin/env bats
|
|
|
|
load test_helper
|
|
|
|
create_executable() {
|
|
local bin="${RBENV_ROOT}/versions/${1}/bin"
|
|
mkdir -p "$bin"
|
|
touch "${bin}/$2"
|
|
chmod +x "${bin}/$2"
|
|
}
|
|
|
|
@test "empty rehash" {
|
|
assert [ ! -d "${RBENV_ROOT}/shims" ]
|
|
run rbenv-rehash
|
|
assert_success ""
|
|
assert [ -d "${RBENV_ROOT}/shims" ]
|
|
rmdir "${RBENV_ROOT}/shims"
|
|
}
|
|
|
|
@test "non-writable shims directory" {
|
|
mkdir -p "${RBENV_ROOT}/shims"
|
|
chmod -w "${RBENV_ROOT}/shims"
|
|
run rbenv-rehash
|
|
assert_failure "rbenv: cannot rehash: ${RBENV_ROOT}/shims isn't writable"
|
|
}
|
|
|
|
@test "rehash in progress" {
|
|
mkdir -p "${RBENV_ROOT}/shims"
|
|
touch "${RBENV_ROOT}/shims/.rbenv-shim"
|
|
run rbenv-rehash
|
|
assert_failure "rbenv: cannot rehash: ${RBENV_ROOT}/shims/.rbenv-shim exists"
|
|
}
|
|
|
|
@test "creates shims" {
|
|
create_executable "1.8" "ruby"
|
|
create_executable "1.8" "rake"
|
|
create_executable "2.0" "ruby"
|
|
create_executable "2.0" "rspec"
|
|
|
|
assert [ ! -e "${RBENV_ROOT}/shims/ruby" ]
|
|
assert [ ! -e "${RBENV_ROOT}/shims/rake" ]
|
|
assert [ ! -e "${RBENV_ROOT}/shims/rspec" ]
|
|
|
|
run rbenv-rehash
|
|
assert_success ""
|
|
|
|
run ls "${RBENV_ROOT}/shims"
|
|
assert_success "\
|
|
rake
|
|
rspec
|
|
ruby"
|
|
}
|