From 92f79ea8def92c3c2373b9ab5f5fa8e03aa7669d Mon Sep 17 00:00:00 2001 From: "Michael S. Klishin" Date: Fri, 5 Sep 2008 22:22:16 +0300 Subject: Make Rack::Lint::InputWrapper delegate size method to underlying IO object. See http://snurl.com/3nesq: Lint was breaking file uploads in a Merb app. Signed-off-by: Michael S. Klishin --- lib/rack/lint.rb | 4 ++++ test/spec_rack_lint.rb | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/rack/lint.rb b/lib/rack/lint.rb index 7bc433b8..79bd9c02 100644 --- a/lib/rack/lint.rb +++ b/lib/rack/lint.rb @@ -215,6 +215,10 @@ module Rack @input = input end + def size + @input.size + end + ## * +gets+ must be called without arguments and return a string, ## or +nil+ on EOF. def gets(*args) diff --git a/test/spec_rack_lint.rb b/test/spec_rack_lint.rb index dbb6687e..3d8c2edb 100644 --- a/test/spec_rack_lint.rb +++ b/test/spec_rack_lint.rb @@ -299,5 +299,17 @@ context "Rack::Lint" do }.should.raise(Rack::Lint::LintError). message.should.match(/close must not be called/) end +end +context "Rack::Lint::InputWrapper" do + specify "delegates :size to underlying IO object" do + class IOMock + def size + 101 + end + end + + wrapper = Rack::Lint::InputWrapper.new(IOMock.new) + wrapper.size.should == 101 + end end -- cgit v1.2.1