2013-04-08 17:00:15 -04:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
|
2015-12-23 21:52:33 -05:00
|
|
|
export GIT_DIR="${RBENV_TEST_DIR}/.git"
|
|
|
|
|
2013-04-08 17:00:15 -04:00
|
|
|
setup() {
|
|
|
|
mkdir -p "$HOME"
|
|
|
|
git config --global user.name "Tester"
|
|
|
|
git config --global user.email "tester@test.local"
|
2015-12-23 21:52:33 -05:00
|
|
|
cd "$RBENV_TEST_DIR"
|
2013-04-08 17:00:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
git_commit() {
|
2013-06-07 13:10:40 -04:00
|
|
|
git commit --quiet --allow-empty -m "empty"
|
2013-04-08 17:00:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "default version" {
|
|
|
|
assert [ ! -e "$RBENV_ROOT" ]
|
|
|
|
run rbenv---version
|
|
|
|
assert_success
|
2015-12-23 21:52:33 -05:00
|
|
|
[[ $output == "rbenv "?.?.? ]]
|
2013-04-08 17:00:15 -04:00
|
|
|
}
|
|
|
|
|
2015-10-25 11:54:38 -04:00
|
|
|
@test "doesn't read version from non-rbenv repo" {
|
|
|
|
git init
|
|
|
|
git remote add origin https://github.com/homebrew/homebrew.git
|
|
|
|
git_commit
|
|
|
|
git tag v1.0
|
|
|
|
|
|
|
|
run rbenv---version
|
|
|
|
assert_success
|
2015-12-23 21:52:33 -05:00
|
|
|
[[ $output == "rbenv "?.?.? ]]
|
2015-10-25 11:54:38 -04:00
|
|
|
}
|
|
|
|
|
2013-04-08 17:00:15 -04:00
|
|
|
@test "reads version from git repo" {
|
|
|
|
git init
|
2015-12-07 14:03:07 -05:00
|
|
|
git remote add origin https://github.com/rbenv/rbenv.git
|
2013-04-08 17:00:15 -04:00
|
|
|
git_commit
|
|
|
|
git tag v0.4.1
|
|
|
|
git_commit
|
|
|
|
git_commit
|
|
|
|
|
|
|
|
run rbenv---version
|
2015-12-23 21:52:33 -05:00
|
|
|
assert_success "rbenv 0.4.1-2-g$(git rev-parse --short HEAD)"
|
2013-04-08 17:00:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "prints default version if no tags in git repo" {
|
|
|
|
git init
|
2015-12-07 14:03:07 -05:00
|
|
|
git remote add origin https://github.com/rbenv/rbenv.git
|
2013-04-08 17:00:15 -04:00
|
|
|
git_commit
|
|
|
|
|
|
|
|
run rbenv---version
|
2015-12-23 21:52:33 -05:00
|
|
|
[[ $output == "rbenv "?.?.? ]]
|
2013-04-08 17:00:15 -04:00
|
|
|
}
|