Class: Rack::MockResponse
Overview
Rack::MockResponse provides useful helpers for testing your apps. Usually, you don't create the MockResponse on your own, but use MockRequest.
Instance Attribute Summary (collapse)
-
- (void) body
inherited
from Response
Returns the value of attribute body.
-
- (void) errors
Errors.
-
- (void) header
(also: #headers)
inherited
from Response
readonly
Returns the value of attribute header.
-
- (void) headers
included
from Response::Helpers
readonly
Headers.
-
- (void) length
inherited
from Response
Returns the value of attribute length.
-
- (void) original_headers
readonly
Headers.
-
- (void) original_headers
included
from Response::Helpers
readonly
Headers.
-
- (void) status
inherited
from Response
Returns the value of attribute status.
Instance Method Summary (collapse)
- - (void) =~(other)
- - (void) body
- - (Boolean) empty?
-
- (MockResponse) initialize(status, headers, body, errors = StringIO.new(""))
constructor
A new instance of MockResponse.
- - (void) match(other)
Constructor Details
- (MockResponse) initialize(status, headers, body, errors = StringIO.new(""))
Returns a new instance of MockResponse
156 157 158 159 160 161 162 |
# File 'rack/rack/mock.rb', line 156 def initialize(status, headers, body, errors=StringIO.new("")) @original_headers = headers @errors = errors.string if errors.respond_to?(:string) @body_string = nil super(body, status, headers) end |
Instance Attribute Details
- (void) body Originally defined in class Response
Returns the value of attribute body
- (void) errors
Errors
154 155 156 |
# File 'rack/rack/mock.rb', line 154 def errors @errors end |
- (void) header (readonly) Also known as: headers Originally defined in class Response
Returns the value of attribute header
- (void) headers (readonly) Originally defined in module Response::Helpers
Headers
- (void) length Originally defined in class Response
Returns the value of attribute length
- (void) original_headers (readonly)
Headers
151 152 153 |
# File 'rack/rack/mock.rb', line 151 def original_headers @original_headers end |
- (void) original_headers (readonly) Originally defined in module Response::Helpers
Headers
- (void) status Originally defined in class Response
Returns the value of attribute status
Instance Method Details
- (void) =~(other)
164 165 166 |
# File 'rack/rack/mock.rb', line 164 def =~(other) body =~ other end |
- (void) body
172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'rack/rack/mock.rb', line 172 def body # FIXME: apparently users of MockResponse expect the return value of # MockResponse#body to be a string. However, the real response object # returns the body as a list. # # See spec_showstatus.rb: # # should "not replace existing messages" do # ... # res.body.should == "foo!" # end super.join end |
- (Boolean) empty?
186 187 188 |
# File 'rack/rack/mock.rb', line 186 def empty? [201, 204, 205, 304].include? status end |
- (void) match(other)
168 169 170 |
# File 'rack/rack/mock.rb', line 168 def match(other) body.match other end |