Skip to content

Commit 82531db

Browse files
committed
docs(globals): add missing helpers and cross-links
1 parent b3a6fb9 commit 82531db

1 file changed

Lines changed: 42 additions & 1 deletion

File tree

docs/globals.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ Internal messages from bashunit include the `[INTERNAL]` prefix so you can easil
3232

3333
> `bashunit::caller_filename`: Gets the caller filename.
3434
35+
## bashunit::caller_line
36+
37+
> `bashunit::caller_line`: Gets the line number of the caller.
38+
39+
Useful inside custom assertions to report the line that triggered the failure.
40+
3541
## bashunit::current_timestamp
3642

3743
> `bashunit::current_timestamp`: Gets the current timestamp.
@@ -54,4 +60,39 @@ The directory is automatically deleted when bashunit completes.
5460

5561
## bashunit::is_command_available
5662

57-
> `bashunit::is_command_available`: Checks if command is available
63+
> `bashunit::is_command_available <command>`: Checks if a command is available in `PATH`.
64+
65+
Returns `0` when the command is found, `1` otherwise.
66+
67+
```bash
68+
if bashunit::is_command_available jq; then
69+
# jq-based assertions
70+
fi
71+
```
72+
73+
## bashunit::print_line
74+
75+
> `bashunit::print_line <?length> <?char>`: Prints a horizontal separator.
76+
77+
Defaults to 70 characters of `-`. Both arguments are optional.
78+
79+
```bash
80+
bashunit::print_line # 70 dashes
81+
bashunit::print_line 40 '=' # 40 equals signs
82+
```
83+
84+
## Custom assertion helpers
85+
86+
These helpers are intended for building [custom assertions](/custom-asserts).
87+
88+
- `bashunit::assertion_passed` — Mark the current assertion as passed.
89+
- `bashunit::assertion_failed <expected> <actual> <?label>` — Mark the current
90+
assertion as failed and print a failure report.
91+
- `bashunit::fail <?message>` — Fail the current test with an optional message.
92+
93+
See [Custom asserts](/custom-asserts) for full examples.
94+
95+
## Test doubles
96+
97+
The `bashunit::spy`, `bashunit::mock`, and `bashunit::unmock` helpers are
98+
documented in [Test doubles](/test-doubles).

0 commit comments

Comments
 (0)