Then(/^response should be '(\d+)'$/) do |code| assert last_response.ok?, "Status is not #{code}, it is #{last_response.status}" end Then(/^the Content\-Type header should include 'application\/json'$/) do assert last_response.header.contenttype.include?("application/json"), "Response has no header 'Content-Type' with 'application/json'" 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 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(/^the JSON response should be a hash$/) do body = JSON.parse(last_response.body) assert body.is_a?(Hash), "Body is not a hash" end Then(/^response should be JSON, images list:$/) do |string| src_image = JSON.parse(string).first image = JSON.parse(last_response.body).first src_image.each do |key, value| assert image.key?(key), "Image has no key '#{key}'" end end Then(/^response should be JSON, image object:$/) do |string| src_image = JSON.parse(string) image = JSON.parse(last_response.body) src_image.each do |key, value| assert image.key?(key), "Image has no key '#{key}'" end end