[rspec-users] matcher for bad request

David Chelimsky dchelimsky at gmail.com
Thu Apr 1 02:37:05 EDT 2010

On Apr 1, 2010, at 1:30 AM, drewB wrote:

> Is there a built-in matcher for a response returning a bad request
> (e.g. header code in the 400s)?  For example, "response.should
> be_bad_request".

No, but its dead simple to write your own:

Spec::Matchers.define :be_bad_request do
  match do |response|
    response.code.to_s =~ /^4/

More information about the rspec-users mailing list