Skip to content

Instantly share code, notes, and snippets.

@dsci
Created July 26, 2012 21:50
Show Gist options
  • Save dsci/3184788 to your computer and use it in GitHub Desktop.
Save dsci/3184788 to your computer and use it in GitHub Desktop.
RSpec Matcher Response Status

Nutzbar wie folgt:

response.should have_status "Found" # 302
response.should have_status "Bad Gateway" # 502
RSpec::Matchers.define :have_status do |expected_status|
match do |response|
status_code = Rack::Utils.status_code(expected_status.downcase.gsub(/\s|-/, '_').to_sym)
response.status == status_code
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment