Then(/^response array should contains elements like:$/) do |string| src = JSON.parse(string).first array = JSON.parse(last_response.body) array.each do |e| src.each do |key, value| assert e.key?(key), "Element #{e.inspect} has no key '#{key}'" end end end Then(/^response array should be empty$/) do array = JSON.parse(last_response.body) assert array.empty?, "Array is not empty" end Then(/^response object should be empty$/) do obj = JSON.parse(last_response.body) assert obj.empty?, "Object is not empty" end Then(/^the JSON response should be an array$/) do body = JSON.parse(last_response.body) assert body.is_a?(Array), "Body is not an array" end Then(/^the JSON response should be an object$/) do body = JSON.parse(last_response.body) assert body.is_a?(Hash), "Body is not an object" end Then(/^the array elements should be strings$/) do body = JSON.parse(last_response.body) body.each do |e| assert e.is_a?(String), "Array element is not a string" end end Then(/^response should be JSON object like:$/) do |string| src = JSON.parse(string) obj = JSON.parse(last_response.body) src.each do |key, value| assert obj.key?(key), "Object has no key '#{key}'" end end