Skip to content

Commit c35ed44

Browse files
committed
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.
1 parent 21a2198 commit c35ed44

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

test/plugins/ruby.plugin.bats

100644100755
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ function local_setup {
88

99
export OLD_PATH="$PATH"
1010
export PATH="/usr/bin:/bin:/usr/sbin"
11-
12-
load ../../plugins/available/ruby.plugin
1311
}
1412

1513
function local_teardown {
@@ -18,15 +16,21 @@ function local_teardown {
1816
}
1917

2018
@test "plugins ruby: remove_gem is defined" {
19+
load ../../plugins/available/ruby.plugin
20+
2121
run type remove_gem
2222
assert_line -n 1 "remove_gem () "
2323
}
2424

2525
@test "plugins ruby: PATH includes ~/.gem/ruby/bin" {
26-
if ! which ruby >/dev/null; then
26+
if ! type ruby >/dev/null; then
2727
skip 'ruby not installed'
2828
fi
2929

30-
local last_path_entry=$(echo $PATH | tr ":" "\n" | tail -1)
31-
[[ "${last_path_entry}" == "${HOME}"/.gem/ruby/*/bin ]]
30+
mkdir -p "$(ruby -e 'print Gem.user_dir')/bin"
31+
32+
load ../../plugins/available/ruby.plugin
33+
34+
local last_path_entry="$(tail -1 <<<"${PATH//:/$'\n'}")"
35+
[[ "${last_path_entry}" == "$(ruby -e 'print Gem.user_dir')/bin" ]]
3236
}

0 commit comments

Comments
 (0)