Skip to content

Instantly share code, notes, and snippets.

@raine
Created June 3, 2011 10:38
Show Gist options
  • Save raine/1006155 to your computer and use it in GitHub Desktop.
Save raine/1006155 to your computer and use it in GitHub Desktop.
RSpec::Matchers.define :respond_with_json do |expected|
match do |actual|
JSON.parse(actual.response.body) == expected
end
failure_message_for_should do |actual|
"expected the response #{actual.response.body} to be #{expected}"
end
end
@raine
Copy link
Author

raine commented Jun 3, 2011

it { should respond_with_json('error' => 'lolcats not found') }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment