plugins/ruby: tests on Mac OS X

Test was failing only on Mac OS X for some reason, so refactor a little.
pull/1904/head
John D Pell 2021-09-08 17:03:36 -07:00
parent 778db5aaad
commit 31bd63f5ed
1 changed files with 7 additions and 6 deletions

View File

@ -3,13 +3,10 @@
load ../test_helper
load ../../lib/helpers
load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
load ../../plugins/available/ruby.plugin
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"
}
@ -20,17 +17,21 @@ function local_teardown {
}
@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 ! which ruby >/dev/null; then
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=$(echo $PATH | tr ":" "\n" | tail -1)
[[ "${last_path_entry}" == "${HOME}"/.gem/ruby/*/bin ]]
local last_path_entry="$(tail -1 <<<"${PATH//:/$'\n'}")"
[[ "${last_path_entry}" == "$(ruby -e 'print Gem.user_dir')/bin" ]]
}