1. Aug 29th, 2007

    be_accepted, be_created, be_forbidden, be_found

    Little addition to your Rails test suite:

    module ActionController
      class AbstractResponse
        StatusCodes::SYMBOL_TO_STATUS_CODE.each do |symbol, code|
          define_method("#{symbol}?") { self.code == code.to_s } unless instance_methods.include?("#{symbol}?")
        end
      end
    end

    You can now assert your favorite status code:

    post :create, params
    assert response.created?

    And with RSpec, you too can be that glorious status code:

    post :create, params
    response.should be_created
    Your comment, here ⇓