[#13885] be_status methods
Reported by Chad Humphries | November 19th, 2007 @ 06:30 AM
response.should be_successful or response.should be_missing are nice but not enough. In too many cases I'm looking for response codes that are neither 200 nor 404.
So how about adding all the status symbols as tests methods?
Controller:
head :unauthorized
Spec:
response.should be_unauthorized
Controller:
head :gone
Spec:
response.should be_gone
And so forth. This code will do it for anything using controller (TestResponse) and integration (CgiResponse) tests:
module ActionController
# TestResponse for functional, CgiResponse for integration.
class AbstractResponse
StatusCodes::SYMBOL_TO_STATUS_CODE.each do |symbol, code|
define_method("#{symbol}?") { self.response_code == code } unless
instance_methods.include?("#{symbol}?")
end
end
end
Comments and changes to this ticket
-
Chad Humphries November 19th, 2007 @ 06:31 AM
Date: 2007-09-23 18:17
Sender: David Chelimsky
I'll add this if you'll submit it as a patch with specs.
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Behaviour Driven Development for Ruby.
People watching this ticket
- Nobody is watching this ticket.
