From 6847c4727482aef979abd794a356c28f6d55a555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Mon, 18 Aug 2014 15:59:59 -0700 Subject: [PATCH] Add rbenv-install tests --- test/rbenv.bats | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 test/rbenv.bats diff --git a/test/rbenv.bats b/test/rbenv.bats new file mode 100644 index 00000000..a07cff3f --- /dev/null +++ b/test/rbenv.bats @@ -0,0 +1,75 @@ +#!/usr/bin/env bats + +load test_helper +export RBENV_ROOT="${TMP}/rbenv" + +setup() { + stub rbenv-hooks 'install : true' + stub rbenv-rehash 'true' +} + +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 rbenv local version by default" { + stub_ruby_build 'echo ruby-build "$1"' + stub rbenv-local 'echo 2.1.2' + + run rbenv-install + assert_success "ruby-build 2.1.2" + + unstub ruby-build + unstub rbenv-local +} + +@test "list available versions" { + stub_ruby_build \ + "--definitions : echo 1.8.7 1.9.3-p0 1.9.3-p194 2.1.2 | tr ' ' $'\\n'" + + run rbenv-install --list + assert_success + assert_output <&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 <