Permalink
Browse files

Add string inclusion into the include-json matcher

  • Loading branch information...
1 parent 053d453 commit decc361177ff0160542807ae5a153a1879920fca @laserlemon laserlemon committed Oct 3, 2012
Showing with 7 additions and 0 deletions.
  1. +1 −0 lib/json_spec/matchers/include_json.rb
  2. +6 −0 spec/json_spec/matchers/include_json_spec.rb
@@ -17,6 +17,7 @@ def matches?(actual_json)
case actual
when Hash then actual.values.map{|v| exclude_keys(v) }.include?(expected)
when Array then actual.map{|e| exclude_keys(e) }.include?(expected)
+ when String then actual.include?(expected)
else false
end
end
@@ -45,6 +45,12 @@
json.should include_json(%([5,6]))
end
+ it "matches a substring" do
+ json = %("json")
+ json.should include_json(%("js"))
+ json.should include_json(%("json"))
+ end
+
it "matches at a path" do
%({"one":{"two":[3,4]}}).should include_json(%([3,4])).at_path("one")
end

0 comments on commit decc361

Please sign in to comment.