From 6fff51aa22a0dcafdf86992d255e33ffcb0867bc Mon Sep 17 00:00:00 2001 From: David G Rosenberg Date: Sun, 14 May 2023 00:01:47 +0800 Subject: [PATCH] Updated readme --- README.md | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bdd4727..8299ced 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,40 @@ # bats-zsh -Wrapper enabling Bats to test Zsh scripts +Wrapper enabling Bats to source and test Zsh scripts. + +## Install +The preferred installation method is via `npm`: +``` +npm install github.com:targendaz2/bats-zsh +``` + +## Usage +This project provides the following functions: +### `zsource` +Used in place of `source` to source a Zsh script. +``` +@test 'zsource sample test'{ + zsource path/to/zsh-script +} +``` +### `zrun` +Used in place of `run` to run a function from the sourced Zsh script. +``` +@test 'output_number_of_args() outputs the number of args' { + zsource path/to/zsh-script + zrun output_number_of_args arg1 arg2 arg3 + + [ "$status" -eq 0 ] + [ "$output" = "there were 23 args" ] + [ "$BATS_RUN_COMMAND" = "zrun output_number_of_args arg1 arg2 arg3" ] +} +``` +All variables expected from `run` will be set (i.e. `status`, `output`, and `BATS_RUN_COMMAND`). + +### Testing +1. Clone this repository +`git clone https://github.com/targendaz2/bats-zsh.git` +2. Install global dependencies (npm & zsh) +3. Install dependencies +`npm install` +4. Run tests +`npm test`