Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ install:
- zsh ~/.zshrc
- sh -c "export BINDIR=$HOME ; `curl -L https://raw.github.com/rylnd/shpec/master/install.sh`"

- chmod +x $HOME/.nvm/nvm.sh
- $HOME/.nvm/nvm.sh
- nvm install 6 && nvm use 6
- (cd test && npm install)
Expand Down
22 changes: 22 additions & 0 deletions resty
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,26 @@ HELP
# With -W option, does not write to history file
[ "$1" = "-W" ] && export _RESTY_NO_HISTORY="/dev/null" && [[ $# -gt 0 ]] && shift

# Force functions to be exported to subshells if it is supported
case "$SHELL" in
*/bash|bash)
declare -fx \
resty \
resty-compute-host-option \
resty-call \
resty-load-alias \
resty-unload-alias \
resty-head \
resty-options \
resty-get \
resty-post \
resty-put \
resty-patch \
resty-delete \
resty-trace \
-resty-help-options
;;
esac


resty "$@" >/dev/null 2>&1
23 changes: 23 additions & 0 deletions test/resty_shpec.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
[[ "$SHELL" == "bash" ]] && shopt -s expand_aliases # needed for bash

RESTY_FUNCTIONS=()
RESTY_FUNCTIONS+=(resty)
RESTY_FUNCTIONS+=(resty-compute-host-option )
RESTY_FUNCTIONS+=(resty-call)
RESTY_FUNCTIONS+=(resty-load-alias)
RESTY_FUNCTIONS+=(resty-unload-alias)
RESTY_FUNCTIONS+=(resty-head)
RESTY_FUNCTIONS+=(resty-options)
RESTY_FUNCTIONS+=(resty-get)
RESTY_FUNCTIONS+=(resty-post)
RESTY_FUNCTIONS+=(resty-put)
RESTY_FUNCTIONS+=(resty-patch)
RESTY_FUNCTIONS+=(resty-delete)
RESTY_FUNCTIONS+=(resty-trace)
RESTY_FUNCTIONS+=(-resty-help-options )

describe "Resty"

describe "Basic"
Expand All @@ -26,6 +42,13 @@ describe "Resty"
assert equal "$output" "hi there"
end

if [ "${SHELL}" == "bash" ]; then
it "should work in a subshell"
exported_functions="$(printf "%d" $(bash -c "declare -F | grep $(printf " -e %s" ${RESTY_FUNCTIONS})" | wc -l))"
assert equal "$exported_functions" "${#RESTY_FUNCTIONS[@]}"
end
fi

end


Expand Down