The matcher you want is:
expect(json.keys).to contain_exactly(:id, :name)
There is also an array match syntax:
So if you have a JSON response that looks something like:
[ "order_statuses" :
[
{
"id" : "id_one",
"name: "a name"
},
{
"id" : "id_one",
"name: "a name"
}
]
]
Then your (pseudo)code might look something like:
json[ "order_statuses" ].each do |status|
expect(status.keys).to contain_exactly( :id, :name )
end