Method: Rack::MockResponse#body
- Defined in:
- lib/rack/mock_response.rb
#body ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/rack/mock_response.rb', line 71 def body return @buffered_body if defined?(@buffered_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 buffer = @buffered_body = String.new begin if @body.respond_to?(:each) @body.each do |chunk| buffer << chunk end else @body.call(StringIO.new(buffer)) end ensure @body.close if @body.respond_to?(:close) end return buffer end |