Class Rack::MockResponse
In: lib/rack/mock.rb
Parent: Object

Rack::MockResponse provides useful helpers for testing your apps. Usually, you don‘t create the MockResponse on your own, but use MockRequest.

Methods

=~   []   match   new  

Included Modules

Response::Helpers

Attributes

body  [R]  Body
errors  [RW]  Errors
headers  [R]  Headers
original_headers  [R]  Headers
status  [R]  Status

Public Class methods

[Source]

     # File lib/rack/mock.rb, line 113
113:     def initialize(status, headers, body, errors=StringIO.new(""))
114:       @status = status.to_i
115: 
116:       @original_headers = headers
117:       @headers = Rack::Utils::HeaderHash.new
118:       headers.each { |field, values|
119:         values.each { |value|
120:           @headers[field] = value
121:         }
122:         @headers[field] = ""  if values.empty?
123:       }
124: 
125:       @body = ""
126:       body.each { |part| @body << part }
127: 
128:       @errors = errors.string
129:     end

Public Instance methods

[Source]

     # File lib/rack/mock.rb, line 145
145:     def =~(other)
146:       @body =~ other
147:     end

[Source]

     # File lib/rack/mock.rb, line 137
137:     def [](field)
138:       headers[field]
139:     end

[Source]

     # File lib/rack/mock.rb, line 149
149:     def match(other)
150:       @body.match other
151:     end

[Validate]