pyenv/test/version-name.bats
Mislav Marohnić 6820704c91 Remove warning about extraneous "ruby-" prefix in .ruby-version
When we started to support reading `.ruby-version` files, we made a
commitment to not support fuzzy version matching. Treating "ruby-2.1.5"
as "2.1.5" is a sort of fuzzy matching, so we put in place a warning
telling you to remove the extraneous "ruby-" prefix popularly used by
other Ruby version managers to denote MRI. (Their logic is that MRI is
"ruby" and other rubies are not "ruby", apparently.)

However, people are often not able to remove the prefix in their
projects because they want to support other coworkers and tools that
sadly still require the prefix, like RubyMine.

So to restore sanity for a big portion of our users, the warning is gone.
2015-01-29 01:55:58 -08:00

61 lines
1.2 KiB
Bash

#!/usr/bin/env bats
load test_helper
create_version() {
mkdir -p "${RBENV_ROOT}/versions/$1"
}
setup() {
mkdir -p "$RBENV_TEST_DIR"
cd "$RBENV_TEST_DIR"
}
@test "no version selected" {
assert [ ! -d "${RBENV_ROOT}/versions" ]
run rbenv-version-name
assert_success "system"
}
@test "system version is not checked for existance" {
RBENV_VERSION=system run rbenv-version-name
assert_success "system"
}
@test "RBENV_VERSION has precedence over local" {
create_version "1.8.7"
create_version "1.9.3"
cat > ".ruby-version" <<<"1.8.7"
run rbenv-version-name
assert_success "1.8.7"
RBENV_VERSION=1.9.3 run rbenv-version-name
assert_success "1.9.3"
}
@test "local file has precedence over global" {
create_version "1.8.7"
create_version "1.9.3"
cat > "${RBENV_ROOT}/version" <<<"1.8.7"
run rbenv-version-name
assert_success "1.8.7"
cat > ".ruby-version" <<<"1.9.3"
run rbenv-version-name
assert_success "1.9.3"
}
@test "missing version" {
RBENV_VERSION=1.2 run rbenv-version-name
assert_failure "rbenv: version \`1.2' is not installed"
}
@test "version with prefix in name" {
create_version "1.8.7"
cat > ".ruby-version" <<<"ruby-1.8.7"
run rbenv-version-name
assert_success
assert_output "1.8.7"
}