Skip to content

Commit

Permalink
more examples on JSON matching
Browse files Browse the repository at this point in the history
  • Loading branch information
amberpixels committed Jul 30, 2024
1 parent 97326f7 commit 737f0a4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,14 @@ Expect(req).To(be_http.Request(
be_json.HaveKeyValue("hello", "world"),
be_json.HaveKeyValue("n", be_reflected.AsInteger(), be_math.GreaterThan(10)),
be_json.HaveKeyValue("ids", be_reflected.AsSliceOf[string]),
Not(be_json.HaveKeyValue("deleted_field")), // not to have a deleted field

be_json.HaveKeyValue("email", be_string.ValidEmail(), be_string.HaveSuffix("@tests.com")),

// "details":[{"key":"foo"},{"key":"bar"}]
be_json.HaveKeyValue("details", And(
be_reflected.AsObjects(),
be.HaveLength(2),
be.HaveLength(be_math.GreaterThan(2)),
ContainElements(
be_json.HaveKeyValue("key", "foo"),
be_json.HaveKeyValue("key", "bar"),
Expand Down

0 comments on commit 737f0a4

Please sign in to comment.