Commit b7237690 authored by Erik Michaels-Ober's avatar Erik Michaels-Ober
Browse files

Merge pull request #766 from jasonkarns/remove-sed-fallback

remove sed fallback for help/usage
parents 67886c84 5013fa8b
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -46,8 +46,7 @@ fi
eval "$(ruby-build --lib)"

usage() {
  # We can remove the sed fallback once rbenv 0.4.0 is widely available.
  rbenv-help install 2>/dev/null || sed -ne '/^#/!q;s/.//;s/.//;1,4d;p' < "$0"
  rbenv-help install 2>/dev/null
  [ -z "$1" ] || exit "$1"
}

+1 −2
Original line number Diff line number Diff line
@@ -18,8 +18,7 @@ if [ "$1" = "--complete" ]; then
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"
  rbenv-help uninstall 2>/dev/null
  [ -z "$1" ] || exit "$1"
}

+26 −4
Original line number Diff line number Diff line
@@ -149,39 +149,61 @@ OUT

@test "not enough arguments for rbenv-install" {
  stub_ruby_build
  stub rbenv-help 'install : true'

  run rbenv-install
  assert_failure
  assert_output_contains 'Usage: rbenv install'
  unstub rbenv-help
}

@test "too many arguments for rbenv-install" {
  stub_ruby_build
  stub rbenv-help 'install : true'

  run rbenv-install 2.1.1 2.1.2
  assert_failure
  assert_output_contains 'Usage: rbenv install'
  unstub rbenv-help
}

@test "show help for rbenv-install" {
  stub_ruby_build
  stub rbenv-help 'install : true'

  run rbenv-install -h
  assert_success
  unstub rbenv-help
}

@test "rbenv-install has usage help preface" {
  run head "$(which rbenv-install)"
  assert_output_contains 'Usage: rbenv install'
}

@test "not enough arguments rbenv-uninstall" {
  stub rbenv-help 'uninstall : true'

  run rbenv-uninstall
  assert_failure
  assert_output_contains 'Usage: rbenv uninstall'
  unstub rbenv-help
}

@test "too many arguments for rbenv-uninstall" {
  stub rbenv-help 'uninstall : true'

  run rbenv-uninstall 2.1.1 2.1.2
  assert_failure
  assert_output_contains 'Usage: rbenv uninstall'
  unstub rbenv-help
}

@test "show help for rbenv-uninstall" {
  stub rbenv-help 'uninstall : true'

  run rbenv-uninstall -h
  assert_success
  unstub rbenv-help
}

@test "rbenv-uninstall has usage help preface" {
  run head "$(which rbenv-uninstall)"
  assert_output_contains 'Usage: rbenv uninstall'
}