Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing tests under rbx and jruby.

  • Loading branch information...
commit 4b4d159e58a956edb15b21316fdcb8f6a87e2563 1 parent 3465d3f
@jakubpawlowicz authored
Showing with 14 additions and 8 deletions.
  1. +14 −8 test/spec_deflater.rb
View
22 test/spec_deflater.rb
@@ -238,7 +238,10 @@ class << body; def each; yield("foo"); yield("bar"); end; end
response = deflater(app, { "min_content_length" => body.length }).call(request)
response[0].should.equal(200)
- gz = Zlib::GzipReader.new(StringIO.new(Enumerator.new(response[2]).to_a.join('')))
+ buf = ''
+ response[2].each { |part| buf << part }
+ io = StringIO.new(buf)
+ gz = Zlib::GzipReader.new(io)
gz.read.should.equal(body)
gz.close
end
@@ -264,15 +267,18 @@ class << body; def each; yield("foo"); yield("bar"); end; end
response = deflater(app, { "exclude" => /^sth$/ }).call(request)
response[0].should.equal(200)
- gz = Zlib::GzipReader.new(StringIO.new(Enumerator.new(response[2]).to_a.join('')))
+ buf = ''
+ response[2].each { |part| buf << part }
+ io = StringIO.new(buf)
+ gz = Zlib::GzipReader.new(io)
gz.read.should.equal(body)
gz.close
end
should "do nothing if :skip_if lambda evaluates to true" do
- body = 'Hello World!'
+ body_text = 'Hello World!'
app = lambda do |env|
- [200, {'Content-Type' => 'text/plain', 'Content-Encoding' => 'identity' }, [body]]
+ [200, {'Content-Type' => 'text/plain', 'Content-Encoding' => 'identity' }, [body_text]]
end
skip_if = lambda do |env, status, header, body|
true
@@ -281,13 +287,13 @@ class << body; def each; yield("foo"); yield("bar"); end; end
response = deflater(app, { "skip_if" => skip_if }).call(request)
response[0].should.equal(200)
- Enumerator.new(response[2]).to_a.join.should.equal(body)
+ Enumerator.new(response[2]).to_a.join.should.equal(body_text)
end
should "deflate response if :skip_if lambda evaluates to false" do
- body = 'Hello World!'
+ body_text = 'Hello World!'
app = lambda do |env|
- [200, {'Content-Type' => 'text/plain', 'Content-Encoding' => 'identity' }, [body]]
+ [200, {'Content-Type' => 'text/plain', 'Content-Encoding' => 'identity' }, [body_text]]
end
skip_if = lambda do |env, status, header, body|
false
@@ -296,6 +302,6 @@ class << body; def each; yield("foo"); yield("bar"); end; end
response = deflater(app, { "skip_if" => skip_if }).call(request)
response[0].should.equal(200)
- inflate(Enumerator.new(response[2]).to_a.join).should.equal(body)
+ inflate(Enumerator.new(response[2]).to_a.join).should.equal(body_text)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.