Permalink
Browse files

Merge pull request #101 from justinmcp/master

Fix operator precedence in IOEncoder.each.
  • Loading branch information...
2 parents 9b03e1e + dca09a7 commit 7f70136f949e2f3508538c52a5b85d360239b78e @seancribbs seancribbs committed Mar 13, 2013
Showing with 11 additions and 1 deletion.
  1. +1 −1 lib/webmachine/streaming/io_encoder.rb
  2. +10 −0 spec/webmachine/decision/helpers_spec.rb
@@ -13,7 +13,7 @@ class IOEncoder < Encoder
# @yield [chunk]
# @yieldparam [String] chunk a chunk of the response, encoded
def each
- while chunk = body.read(CHUNK_SIZE) && chunk != ""
+ while (chunk = body.read(CHUNK_SIZE)) && chunk != ""
yield resource.send(encoder, resource.send(charsetter, chunk))
end
end
@@ -156,6 +156,16 @@ def accept_doc; result; end
response.headers['Content-Length'].should == File.stat('spec/spec_helper.rb').size.to_s
end
+ it "progressively yields file contents for each enumeration" do
+ subject.encode_body
+ body_size = 0
+ response.body.each do |chunk|
+ chunk.should be_a(String)
+ body_size += chunk.length
+ end
+ body_size.should == File.stat('spec/spec_helper.rb').size
+ end
+
context "when the resource provides a non-identity encoding that the client accepts" do
let(:resource) do
resource_with do

0 comments on commit 7f70136

Please sign in to comment.