Skip to content

Instantly share code, notes, and snippets.

@ukstudio
Created March 5, 2012 03:51
Show Gist options
  • Save ukstudio/1976457 to your computer and use it in GitHub Desktop.
Save ukstudio/1976457 to your computer and use it in GitHub Desktop.
rspec-http-matchers
Rack::Utils::SYMBOL_TO_STATUS_CODE.each do |symbol,code|
matcher_name = symbol.to_s =~ /^not_/ ? symbol : "be_#{symbol}"
RSpec::Matchers.define matcher_name do
match do |response|
response.code.to_i == code
end
end
end
# subject { response }
# it { should be_success }
# it { should not_found }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment