Expanded matchers for JSON matching
Go
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
LICENSE.md
README.md
expanded_json_matcher.go
expanded_json_matcher_test.go
expanded_unmarshalled_matchers.go
expanded_unmarshalled_matchers_suite_test.go
expanded_yaml_matcher.go
expanded_yaml_matcher_test.go
unmarshalled_deep_matcher.go

README.md

Gomega matchers for more complicated json matching

This package provides Gomega matchers to match against either subsets of json/yaml, as well as json/yaml that has unordered lists. You can see an example of what that means below.

The functions of this library should follow the following pattern

(Match|Contain)(Ordered|Unordered)(JSON|YAML)( aStructureToUnmarshall, optional (With(Un)orderedListKeys(keys))

JsonMatchers()

import (
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	. "github.com/Benjamintf1/ExpandedUnmarshalledMatchers"
)

//Match with list ordering and optional json list keys exceptions
Expect(`{"a":[1,2,3],"b":[1,2,3],"c":[1,2,3]}`).Should(
	MatchUnorderedJSON(`{"a":[1,2,3],"b":[3,2,1],"c":[3,2,1]}`,
		WithOrderedListKeys("a"))) 
		
Expect(`{"a":[1,2,3],"b":[1,2,3],"c":[1,2,3]}`).Should(
	MatchOrderedJSON(`{"a":[3,2,1],"b":[1,2,3],"c":[1,2,3]}`,
		WithUnorderedListKeys("a")))

//Contain with list ordering and optional json list keys exceptions
Expect(`{"a":[1,2,3],"b":[1,2,3],"c":[1,2,3]}`).Should(
	ContainUnorderedJSON(`{"a":[1,2,3],"b":[3,2,1]}`,
		WithOrderedListKeys("a")))
		
Expect(`{"a":[1,2,3],"b":[1,2,3],"c":[1,2,3]}`).Should(
	ContainOrderedJSON(`{"a":[3,2,1],"b":[1,2,3]}`, 
		WithUnorderedListKeys("a")))