#!/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" } stub_system_ruby() { local stub="${RBENV_TEST_DIR}/bin/ruby" mkdir -p "$(dirname "$stub")" touch "$stub" && chmod +x "$stub" } @test "no versions installed" { stub_system_ruby assert [ ! -d "${RBENV_ROOT}/versions" ] run rbenv-versions assert_success "* system" } @test "not even system ruby available" { PATH="$(path_without ruby)" run rbenv-versions assert_failure assert_output "Warning: no Ruby detected on the system" } @test "bare output no versions installed" { assert [ ! -d "${RBENV_ROOT}/versions" ] run rbenv-versions --bare assert_success "" } @test "single version installed" { stub_system_ruby create_version "1.9" run rbenv-versions assert_success assert_output < "${RBENV_ROOT}/version" <<<"1.9.3" run rbenv-versions assert_success assert_output < ".ruby-version" <<<"1.9.3" run rbenv-versions assert_success assert_output <