From 0f7a2cad8d497cce55b25035e4cf65a5bbe588de Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Tue, 29 Dec 2015 11:01:10 -0500 Subject: [PATCH] Use create_hook helper Use extracted create_hook helper in tests for: - exec - hooks - rehash - version-name - version-origin - which --- test/exec.bats | 6 ++---- test/hooks.bats | 27 +++++++++++++-------------- test/rehash.bats | 6 ++---- test/version-name.bats | 8 ++------ test/version-origin.bats | 7 ++----- test/which.bats | 6 ++---- 6 files changed, 23 insertions(+), 37 deletions(-) diff --git a/test/exec.bats b/test/exec.bats index 42948c5c..5413912b 100644 --- a/test/exec.bats +++ b/test/exec.bats @@ -44,15 +44,13 @@ OUT } @test "carries original IFS within hooks" { - hook_path="${RBENV_TEST_DIR}/rbenv.d" - mkdir -p "${hook_path}/exec" - cat > "${hook_path}/exec/hello.bash" <" @@ -15,11 +10,13 @@ create_hook() { @test "prints list of hooks" { path1="${RBENV_TEST_DIR}/rbenv.d" path2="${RBENV_TEST_DIR}/etc/rbenv_hooks" - create_hook "$path1" exec "hello.bash" - create_hook "$path1" exec "ahoy.bash" - create_hook "$path1" exec "invalid.sh" - create_hook "$path1" which "boom.bash" - create_hook "$path2" exec "bueno.bash" + RBENV_HOOK_PATH="$path1" + create_hook exec "hello.bash" + create_hook exec "ahoy.bash" + create_hook exec "invalid.sh" + create_hook which "boom.bash" + RBENV_HOOK_PATH="$path2" + create_hook exec "bueno.bash" RBENV_HOOK_PATH="$path1:$path2" run rbenv-hooks exec assert_success @@ -33,8 +30,10 @@ OUT @test "supports hook paths with spaces" { path1="${RBENV_TEST_DIR}/my hooks/rbenv.d" path2="${RBENV_TEST_DIR}/etc/rbenv hooks" - create_hook "$path1" exec "hello.bash" - create_hook "$path2" exec "ahoy.bash" + RBENV_HOOK_PATH="$path1" + create_hook exec "hello.bash" + RBENV_HOOK_PATH="$path2" + create_hook exec "ahoy.bash" RBENV_HOOK_PATH="$path1:$path2" run rbenv-hooks exec assert_success @@ -45,8 +44,8 @@ OUT } @test "resolves relative paths" { - path="${RBENV_TEST_DIR}/rbenv.d" - create_hook "$path" exec "hello.bash" + RBENV_HOOK_PATH="${RBENV_TEST_DIR}/rbenv.d" + create_hook exec "hello.bash" mkdir -p "$HOME" RBENV_HOOK_PATH="${HOME}/../rbenv.d" run rbenv-hooks exec diff --git a/test/rehash.bats b/test/rehash.bats index 74f55a97..15d7a89b 100755 --- a/test/rehash.bats +++ b/test/rehash.bats @@ -105,15 +105,13 @@ OUT } @test "carries original IFS within hooks" { - hook_path="${RBENV_TEST_DIR}/rbenv.d" - mkdir -p "${hook_path}/rehash" - cat > "${hook_path}/rehash/hello.bash" < "${RBENV_ROOT}/rbenv.d/version-name/test.bash" < "${RBENV_ROOT}/rbenv.d/version-origin/test.bash" < "${hook_path}/which/hello.bash" <