Loading bin/rbenv-install +2 −0 Original line number Diff line number Diff line Loading @@ -111,6 +111,8 @@ DEFINITION="${ARGUMENTS[0]}" [ -n "$DEFINITION" ] || DEFINITION="$(rbenv-local 2>/dev/null || true)" [ -n "$DEFINITION" ] || usage 1 # Fail if number of arguments is greater than 1 [ "${#ARGUMENTS[@]}" -le 1 ] || usage 1 # Define `before_install` and `after_install` functions that allow # plugin hooks to register a string of code for execution before or Loading bin/rbenv-uninstall +9 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,12 @@ if [ "$1" = "--complete" ]; then exec rbenv versions --bare fi usage() { # We can remove the sed fallback once rbenv 0.4.0 is widely available. rbenv-help uninstall 2>/dev/null || sed -ne '/^#/!q;s/.//;s/.//;1,4d;p' < "$0" [ -z "$1" ] || exit "$1" } if [ -z "$RBENV_ROOT" ]; then RBENV_ROOT="${HOME}/.rbenv" fi Loading @@ -38,6 +44,9 @@ case "$DEFINITION" in ;; esac # Fail if number of arguments is not equal 1 [ "$#" -eq 1 ] || usage 1 declare -a before_hooks after_hooks before_uninstall() { Loading bin/ruby-build +3 −0 Original line number Diff line number Diff line Loading @@ -1046,6 +1046,9 @@ elif [ "${PREFIX_PATH#/}" = "$PREFIX_PATH" ]; then PREFIX_PATH="${PWD}/${PREFIX_PATH}" fi # Fail if number of arguments is not equal to 2 [ "${#ARGUMENTS[@]}" -eq 2 ] || usage if [ -z "$TMPDIR" ]; then TMP="/tmp" else Loading test/arguments.bats 0 → 100644 +53 −0 Original line number Diff line number Diff line #!/usr/bin/env bats load test_helper @test "not enought arguments for ruby-build" { # use empty inline definition so nothing gets built anyway local definition="${TMP}/build-definition" echo '' > "$definition" run ruby-build "$definition" assert_failure assert_output_contains 'usage: ruby-build' } @test "extra arguments for ruby-build" { # use empty inline definition so nothing gets built anyway local definition="${TMP}/build-definition" echo '' > "$definition" run ruby-build "$definition" 2.1.2 "${TMP}/install" assert_failure assert_output_contains 'usage: ruby-build' } @test "extra arguments for rbenv-install" { stub ruby-build "--lib : $BATS_TEST_DIRNAME/../bin/ruby-build --lib" stub rbenv-hooks stub rbenv-rehash run rbenv-install 2.1.1 2.1.2 assert_failure assert_output_contains 'Usage: rbenv install' unstub ruby-build unstub rbenv-hooks unstub rbenv-rehash } @test "not enough arguments rbenv-uninstall" { run rbenv-uninstall assert_failure assert_output_contains 'Usage: rbenv uninstall' } @test "extra arguments for rbenv-uninstall" { stub rbenv-hooks run rbenv-uninstall 2.1.1 2.1.2 assert_failure assert_output_contains 'Usage: rbenv uninstall' unstub rbenv-hooks } Loading
bin/rbenv-install +2 −0 Original line number Diff line number Diff line Loading @@ -111,6 +111,8 @@ DEFINITION="${ARGUMENTS[0]}" [ -n "$DEFINITION" ] || DEFINITION="$(rbenv-local 2>/dev/null || true)" [ -n "$DEFINITION" ] || usage 1 # Fail if number of arguments is greater than 1 [ "${#ARGUMENTS[@]}" -le 1 ] || usage 1 # Define `before_install` and `after_install` functions that allow # plugin hooks to register a string of code for execution before or Loading
bin/rbenv-uninstall +9 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,12 @@ if [ "$1" = "--complete" ]; then exec rbenv versions --bare fi usage() { # We can remove the sed fallback once rbenv 0.4.0 is widely available. rbenv-help uninstall 2>/dev/null || sed -ne '/^#/!q;s/.//;s/.//;1,4d;p' < "$0" [ -z "$1" ] || exit "$1" } if [ -z "$RBENV_ROOT" ]; then RBENV_ROOT="${HOME}/.rbenv" fi Loading @@ -38,6 +44,9 @@ case "$DEFINITION" in ;; esac # Fail if number of arguments is not equal 1 [ "$#" -eq 1 ] || usage 1 declare -a before_hooks after_hooks before_uninstall() { Loading
bin/ruby-build +3 −0 Original line number Diff line number Diff line Loading @@ -1046,6 +1046,9 @@ elif [ "${PREFIX_PATH#/}" = "$PREFIX_PATH" ]; then PREFIX_PATH="${PWD}/${PREFIX_PATH}" fi # Fail if number of arguments is not equal to 2 [ "${#ARGUMENTS[@]}" -eq 2 ] || usage if [ -z "$TMPDIR" ]; then TMP="/tmp" else Loading
test/arguments.bats 0 → 100644 +53 −0 Original line number Diff line number Diff line #!/usr/bin/env bats load test_helper @test "not enought arguments for ruby-build" { # use empty inline definition so nothing gets built anyway local definition="${TMP}/build-definition" echo '' > "$definition" run ruby-build "$definition" assert_failure assert_output_contains 'usage: ruby-build' } @test "extra arguments for ruby-build" { # use empty inline definition so nothing gets built anyway local definition="${TMP}/build-definition" echo '' > "$definition" run ruby-build "$definition" 2.1.2 "${TMP}/install" assert_failure assert_output_contains 'usage: ruby-build' } @test "extra arguments for rbenv-install" { stub ruby-build "--lib : $BATS_TEST_DIRNAME/../bin/ruby-build --lib" stub rbenv-hooks stub rbenv-rehash run rbenv-install 2.1.1 2.1.2 assert_failure assert_output_contains 'Usage: rbenv install' unstub ruby-build unstub rbenv-hooks unstub rbenv-rehash } @test "not enough arguments rbenv-uninstall" { run rbenv-uninstall assert_failure assert_output_contains 'Usage: rbenv uninstall' } @test "extra arguments for rbenv-uninstall" { stub rbenv-hooks run rbenv-uninstall 2.1.1 2.1.2 assert_failure assert_output_contains 'Usage: rbenv uninstall' unstub rbenv-hooks }