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:       }
123: 
124:       @body = ""
125:       body.each { |part| @body << part }
126: 
127:       @errors = errors.string
128:     end

Public Instance methods

[Source]

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

[Source]

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

[Source]

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

[Validate]