Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HTTP::Response#flush #125

Merged
merged 1 commit into from Apr 20, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/http/response.rb
Expand Up @@ -95,6 +95,12 @@ def to_s
end
alias_method :to_str, :to_s

# Flushes body and returns self-reference
def flush
body.to_s
self
end

# Parsed Content-Type header
# @return [HTTP::ContentType]
def content_type
Expand Down
14 changes: 14 additions & 0 deletions spec/http/response_spec.rb
Expand Up @@ -83,4 +83,18 @@
end
end
end

describe '#flush' do
let(:body) { double :to_s => '' }
let(:response) { HTTP::Response.new 200, '1.1', {}, body }

it 'returns response self-reference' do
expect(response.flush).to be response
end

it 'flushes body' do
expect(body).to receive :to_s
response.flush
end
end
end