diff --git a/plugins/available/base.plugin.bash b/plugins/available/base.plugin.bash index 10f5a2bf..8c8a2c50 100644 --- a/plugins/available/base.plugin.bash +++ b/plugins/available/base.plugin.bash @@ -25,7 +25,6 @@ function myip () echo -e "Your public IP is: ${echo_bold_green} $res ${echo_normal}" } - function pickfrom () { about 'picks random line from file' @@ -92,7 +91,6 @@ function lsgrep () ls | grep "$*" } - function pman () { about 'view man documentation in Preview' @@ -102,7 +100,6 @@ function pman () man -t "${1}" | open -f -a $PREVIEW } - function pcurl () { about 'download file and Preview it' @@ -125,16 +122,16 @@ function quiet () { about 'what *does* this do?' group 'base' - $* &> /dev/null & + $* &> /dev/null & } function banish-cookies () { about 'redirect .adobe and .macromedia files to /dev/null' group 'base' - rm -r ~/.macromedia ~/.adobe - ln -s /dev/null ~/.adobe - ln -s /dev/null ~/.macromedia + rm -r ~/.macromedia ~/.adobe + ln -s /dev/null ~/.adobe + ln -s /dev/null ~/.macromedia } function usage () @@ -184,7 +181,6 @@ function command_exists () mkiso () { - about 'creates iso from current dir in the parent dir (unless defined)' param '1: ISO name' param '2: dest/path' diff --git a/test/plugins/base.plugin.bats b/test/plugins/base.plugin.bats new file mode 100755 index 00000000..9bc9f0e6 --- /dev/null +++ b/test/plugins/base.plugin.bats @@ -0,0 +1,36 @@ +#!/usr/bin/env bats + +load ../test_helper +load ../../lib/composure +load ../../plugins/available/base.plugin + +@test 'plugins base: ips()' { + if [[ $CI ]]; then + skip 'ifconfig probably requires sudo on TravisCI' + fi + + declare -r localhost='127.0.0.1' + run ips + assert_success + assert_line $localhost +} + +@test 'plugins base: myip()' { + if [[ ! $CI ]]; then + skip 'myip is slow - run only on CI' + fi + + run myip + assert_success + declare -r mask_ip=$(echo $output | tr -s '[0-9]' '?') + [[ $mask_ip == 'Your public IP is: ?.?.?.?' ]] +} + +@test 'plugins base: pickfrom()' { + mkdir -p $BASH_IT_ROOT + stub_file="${BASH_IT_ROOT}/stub_file" + printf "l1\nl2\nl3" > $stub_file + run pickfrom $stub_file + assert_success + [[ $output == l? ]] +} diff --git a/test/test_helper.bash b/test/test_helper.bash index da34c438..850b6161 100644 --- a/test/test_helper.bash +++ b/test/test_helper.bash @@ -1,4 +1,3 @@ -unset BASH_IT unset BASH_IT_THEME unset GIT_HOSTING unset NGINX_PATH @@ -6,7 +5,13 @@ unset IRC_CLIENT unset TODO unset SCM_CHECK -BASH_IT_TEST_DIR="${BATS_TMPDIR}/bash_it" +BASH_IT_TEST_DIR="${BATS_TMPDIR}/.bash_it" + +# guard against executing this block twice due to bats internals +if [ "$BASH_IT_ROOT" != "${BASH_IT_TEST_DIR}/root" ]; then + export BASH_IT_ROOT="${BASH_IT_TEST_DIR}/root" + export BASH_IT=$BASH_IT_TEST_DIR +fi teardown() { rm -rf "$BASH_IT_TEST_DIR"