From c35ed44cbf8b45da1257a2071400bcc3a3208e87 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. It turned out to be due to explicitly setting `$HOME` *after* loading the plugin. --- test/plugins/ruby.plugin.bats | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) mode change 100644 => 100755 test/plugins/ruby.plugin.bats diff --git a/test/plugins/ruby.plugin.bats b/test/plugins/ruby.plugin.bats old mode 100644 new mode 100755 index dc8a3e85..e40dfeae --- a/test/plugins/ruby.plugin.bats +++ b/test/plugins/ruby.plugin.bats @@ -8,8 +8,6 @@ function local_setup { export OLD_PATH="$PATH" export PATH="/usr/bin:/bin:/usr/sbin" - - load ../../plugins/available/ruby.plugin } function local_teardown { @@ -18,15 +16,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 - local last_path_entry=$(echo $PATH | tr ":" "\n" | tail -1) - [[ "${last_path_entry}" == "${HOME}"/.gem/ruby/*/bin ]] + 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" ]] }