Skip to content

Commit 3e2b256

Browse files
committed
Update expects documentation with comprehensive examples
Add extensive examples for: - Basic usage with both success and failure cases - String operations (to_contain, to_match) - Value checks (to_be_true/false, to_be_defined) - Negation syntax (not to_*) Part of #24
1 parent 56be66b commit 3e2b256

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

bin/expects

+42-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,55 @@
22

33
# A smaller test API like [Jest](https://jestjs.io/ja/docs/expect) for bash script.
44
#
5+
# ## Basic Usage
56
# ```shell-session
7+
# # Positive assertions
68
# $ x=10
79
# $ expects "$x" to_be 10 && echo Success
810
# Success
9-
# ```
10-
# ```shell-session
11+
#
12+
# # Negative assertions
1113
# $ x=10
1214
# $ expects "$x" not to_be 42 && echo Success
1315
# Success
16+
#
17+
# # Failed assertions
18+
# $ x=42
19+
# $ expects "$x" to_be 10
20+
# FAIL: expected {actual} to_be 10, but {actual} is: 42
21+
# ```
22+
#
23+
# ## String Operations
24+
# ```shell-session
25+
# # String containment
26+
# $ str="hello world"
27+
# $ expects "$str" to_contain "world" && echo Success
28+
# Success
29+
# $ expects "$str" not to_contain "moon" && echo Success
30+
# Success
31+
#
32+
# # Pattern matching
33+
# $ str="hello123"
34+
# $ expects "$str" to_match "^[a-z]+[0-9]+$" && echo Success
35+
# Success
36+
# $ expects "$str" not to_match "^[0-9]+$" && echo Success
37+
# Success
38+
# ```
39+
#
40+
# ## Value Checks
41+
# ```shell-session
42+
# # Boolean assertions
43+
# $ expects true to_be_true && echo Success
44+
# Success
45+
# $ expects false to_be_false && echo Success
46+
# Success
47+
#
48+
# # Existence checks
49+
# $ var="some value"
50+
# $ expects "$var" to_be_defined && echo Success
51+
# Success
52+
# $ expects "" not to_be_defined && echo Success
53+
# Success
1454
# ```
1555

1656
actual_value=$1

0 commit comments

Comments
 (0)