Skip to content

Commit decc361

Browse files
committed
Add string inclusion into the include-json matcher
1 parent 053d453 commit decc361

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/json_spec/matchers/include_json.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def matches?(actual_json)
1717
case actual
1818
when Hash then actual.values.map{|v| exclude_keys(v) }.include?(expected)
1919
when Array then actual.map{|e| exclude_keys(e) }.include?(expected)
20+
when String then actual.include?(expected)
2021
else false
2122
end
2223
end

spec/json_spec/matchers/include_json_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@
4545
json.should include_json(%([5,6]))
4646
end
4747

48+
it "matches a substring" do
49+
json = %("json")
50+
json.should include_json(%("js"))
51+
json.should include_json(%("json"))
52+
end
53+
4854
it "matches at a path" do
4955
%({"one":{"two":[3,4]}}).should include_json(%([3,4])).at_path("one")
5056
end

0 commit comments

Comments
 (0)