Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find Way to Mock Out Util Without Code Change #29

Open
ReedClanton opened this issue Apr 11, 2023 · 0 comments
Open

Find Way to Mock Out Util Without Code Change #29

ReedClanton opened this issue Apr 11, 2023 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed question Further information is requested

Comments

@ReedClanton
Copy link
Owner

Description

Currently the only way I've found to mock out util (constants, globals, helper functions, etc) when running shellspec tests is to add the bellow block to the top of the primary shell script:

# Needed so unit tests can mock out sourced file(s).
if [ "$(type -t inScriptSource)" = "" ]; then
	inScriptSource() { . "${@}"; }
fi

Then use inScriptSource() in place of . when sourcing main.sh.

Example

See the output() function (src/shell/functions/output/output.sh).

DOD

Mock out util contents without having to change CUT.

@ReedClanton ReedClanton added enhancement New feature or request help wanted Extra attention is needed question Further information is requested labels Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant