Skip to content

Commit

Permalink
Updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
targendaz2 committed May 13, 2023
1 parent d780acf commit 6fff51a
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion README.md
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`

0 comments on commit 6fff51a

Please sign in to comment.