collectiveidea/json_spec — pull request #41 by marshallshen (2013-05-04 17:12:50+00:00)
Title: Extend include_json to match elements inside an array of hash

Background:
Right now include_json can't test a specific element inside a hash that is included in an array.
I understand that the package comes with exclude_keys, but it'd be handy if it can only match up the elements that I care about.

Use case
==============
Given actual (json object) and expected(hash):

JSON.parse(actual)
[{"name" => "Mike", "gender" => "male"}, {"name" => "Abby", "gender" => "female"}]

expected

{"name" => "Abby"}
actual.should include_json(expected.to_json)
> false

because the following is false:
[{"name" => "Mike", "gender" => "male"}, {"name" => "Abby", "gender" => "female"}].include?({"name" => "Abby"})
================

This patch will make include_json true.