-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d780acf
commit 6fff51a
Showing
1 changed file
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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` |