Skip to content

Commit

Permalink
warn user that installation will fail if she doesn't have necessary w…
Browse files Browse the repository at this point in the history
…rite permission
  • Loading branch information
Mizou04 committed Sep 6, 2023
1 parent 61a627e commit a17f424
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bin/ruby-install
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ fi

init || exit $?

if [[ ! -w "$install_dir" ]]; then
log "seems like you need necessary write permission on $install_dir"
exit 1
fi

if [[ $no_reinstall -eq 1 ]] && [[ -x "$install_dir/bin/ruby" ]]; then
log "Ruby is already installed into $install_dir"
exit
Expand Down
27 changes: 27 additions & 0 deletions test/cli-tests/no_permission_warn_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

. ./test/helper.sh

test_install_dir="$test_fixtures_dir/no_permission_warn_test"

function setUp()
{
mkdir -p $test_install_dir
chmod -w $test_install_dir
}

function test_no_install_when_write_permissions_lacking()
{
local output="$(ruby-install --install-dir "$test_install_dir" ruby)"

assertEquals "did not return 0" 0 $?
assertTrue "did not print a message to STDOUT" \
'[[ "$output" == *"need necessary write permission"* ]]'
}

function tearDown()
{
rm -rf "$test_install_dir"
}

SHUNIT_PARENT=$0 . $SHUNIT2

0 comments on commit a17f424

Please sign in to comment.