#!/usr/bin/env bats load test_helper export RBENV_ROOT="${TMP}/rbenv" setup() { stub rbenv-hooks 'install : true' stub rbenv-rehash 'true' stub rbenv-version-file 'echo $RBENV_ROOT/version' mkdir -p "$RBENV_ROOT" echo "system" > "$RBENV_ROOT/version" } stub_ruby_build() { stub ruby-build "--lib : $BATS_TEST_DIRNAME/../bin/ruby-build --lib" "$@" } @test "install proper" { stub_ruby_build 'echo ruby-build "$@"' run rbenv-install 2.1.2 assert_success "ruby-build 2.1.2 ${RBENV_ROOT}/versions/2.1.2" unstub ruby-build unstub rbenv-hooks unstub rbenv-rehash } @test "install with flags" { stub_ruby_build 'echo "ruby-build $(inspect_args "$@")"' run rbenv-install -kpv 2.1.2 -- --with-configure-opt="hello world" assert_success "ruby-build --keep --verbose --patch 2.1.2 ${RBENV_ROOT}/versions/2.1.2 -- \"--with-configure-opt=hello world\"" unstub ruby-build unstub rbenv-hooks unstub rbenv-rehash } @test "suggest running rbenv global after install" { rm -rf "$RBENV_ROOT/version" stub_ruby_build 'echo ruby-build "$@"' run rbenv-install 2.1.2 assert_success <&2 && exit 2' \ "--definitions : echo 1.8.7 1.9.3-p0 1.9.3-p194 2.1.2 | tr ' ' $'\\n'" run rbenv-install 1.9.3 assert_failure assert_output <&2 && exit 2' \ "--definitions : true" run rbenv-install 1.9.3 assert_failure assert_output <