Permalink
Browse files

Fixed tests to be Ruby 1.8.x compatible.

  • Loading branch information...
1 parent 4e883df commit fd9739f92b3218fccd6e487d87674804c41dbae9 @jakubpawlowicz committed Nov 14, 2012
Showing with 9 additions and 9 deletions.
  1. +3 −3 lib/rack/deflater.rb
  2. +6 −6 test/spec_deflater.rb
View
6 lib/rack/deflater.rb
@@ -8,9 +8,9 @@ class Deflater
def initialize(app, options = {})
@app = app
- @min_content_length = options[:min_content_length]
- @skip_if = options[:skip_if]
- @exclude = options[:exclude]
+ @min_content_length = options[:min_content_length] || options['min_content_length']
+ @skip_if = options[:skip_if] || options['skip_if']
+ @exclude = options[:exclude] || options['exclude']
end
def call(env)
View
12 test/spec_deflater.rb
@@ -211,7 +211,7 @@ class << body; def each; yield("foo"); yield("bar"); end; end
[200, {'Content-Type' => 'text/plain', 'Content-Length' => body.length.to_s }, [body]]
end
request = Rack::MockRequest.env_for("", "HTTP_ACCEPT_ENCODING" => "gzip")
- response = deflater(app, { min_content_length: body.length + 1 }).call(request)
+ response = deflater(app, { "min_content_length" => body.length + 1 }).call(request)
response[0].should.equal(200)
Enumerator.new(response[2]).to_a.join.should.equal("Hello World!")
@@ -223,7 +223,7 @@ class << body; def each; yield("foo"); yield("bar"); end; end
[200, {'Content-Type' => 'text/plain', 'Content-Length' => body.length.to_s }, [body]]
end
request = Rack::MockRequest.env_for("", "HTTP_ACCEPT_ENCODING" => "gzip")
- response = deflater(app, { min_content_length: body.length + 1 }).call(request)
+ response = deflater(app, { "min_content_length" => body.length + 1 }).call(request)
response[0].should.equal(200)
Enumerator.new(response[2]).to_a.join.should.equal("Hello World!")
@@ -235,7 +235,7 @@ class << body; def each; yield("foo"); yield("bar"); end; end
[200, {'Content-Type' => 'text/plain', 'Content-Length' => body.length.to_s }, [body]]
end
request = Rack::MockRequest.env_for("", "HTTP_ACCEPT_ENCODING" => "gzip")
- response = deflater(app, { min_content_length: body.length }).call(request)
+ 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('')))
@@ -261,7 +261,7 @@ class << body; def each; yield("foo"); yield("bar"); end; end
[200, {'Content-Type' => 'text/plain', 'Content-Length' => body.length.to_s }, [body]]
end
request = Rack::MockRequest.env_for("", "HTTP_ACCEPT_ENCODING" => "gzip")
- response = deflater(app, { exclude: /^sth$/ }).call(request)
+ 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('')))
@@ -278,7 +278,7 @@ class << body; def each; yield("foo"); yield("bar"); end; end
true
end
request = Rack::MockRequest.env_for("", "HTTP_ACCEPT_ENCODING" => "gzip")
- response = deflater(app, { skip_if: skip_if }).call(request)
+ response = deflater(app, { "skip_if" => skip_if }).call(request)
response[0].should.equal(200)
Enumerator.new(response[2]).to_a.join.should.equal(body)
@@ -293,7 +293,7 @@ class << body; def each; yield("foo"); yield("bar"); end; end
false
end
request = Rack::MockRequest.env_for("", "HTTP_ACCEPT_ENCODING" => "deflate")
- response = deflater(app, { skip_if: skip_if }).call(request)
+ 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)

0 comments on commit fd9739f

Please sign in to comment.