From 31bd63f5ed283b8fa8f9284aff5d3165572f533c Mon Sep 17 00:00:00 2001 From: John D Pell Date: Wed, 8 Sep 2021 17:03:36 -0700 Subject: [PATCH] plugins/ruby: tests on Mac OS X Test was failing only on Mac OS X for some reason, so refactor a little. --- test/plugins/ruby.plugin.bats | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/plugins/ruby.plugin.bats b/test/plugins/ruby.plugin.bats index 3d5bad27..36b8f196 100755 --- a/test/plugins/ruby.plugin.bats +++ b/test/plugins/ruby.plugin.bats @@ -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" ]] }