Files
bash-it/test/plugins/ruby.plugin.bats
John D Pell 5eab3bd288 lib/helpers: first shellcheck pass
Quote things, SC2268, SC2143, SC2181, SC2162, SC2016, SC2013, &c.

Rewrite globbing per `shellcheck`’s SC2013, and alsö s/typeset/local/g. Eliminate `compgen` where possible.

Alsö: use the existing utility functions `_bash-it-get-component-type-from-path` and `_bash-it-get-component-name-from-path`, which just use parameter substitution anyway. Why was `sed` here?

Alsö, don't add not-existing directories to `$PATH` in `pathmunge()`.

Finally, merge PR #1865 from NoahGorny...and clean it a bit...
2022-01-18 11:02:21 -08:00

39 lines
829 B
Bash
Executable File

#!/usr/bin/env bats
load ../test_helper
load ../test_helper_libs
function local_setup {
setup_test_fixture
_command_exists "ruby" && mkdir -p "$(ruby -e 'print Gem.user_dir')/bin"
export OLD_PATH="$PATH"
export PATH="/usr/bin:/bin:/usr/sbin"
}
function local_teardown {
export PATH="$OLD_PATH"
unset OLD_PATH
}
@test "plugins ruby: remove_gem is defined" {
load ../../plugins/available/ruby.plugin
run type remove_gem
assert_line -n 1 "remove_gem () "
}
@test "plugins ruby: PATH includes ~/.gem/ruby/bin" {
if ! type ruby >/dev/null; then
skip 'ruby not installed'
fi
mkdir -p "$(ruby -e 'print Gem.user_dir')/bin"
load ../../plugins/available/ruby.plugin
local last_path_entry="$(tail -1 <<<"${PATH//:/$'\n'}")"
[[ "${last_path_entry}" == "$(ruby -e 'print Gem.user_dir')/bin" ]]
}