diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2020-01-07 19:22:15 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-07 19:22:15 +1300 |
commit | bf0e41dc79bd0e7ca21bc077f122ed446e2de03c (patch) | |
tree | 9d73deb1f8bbfce9448495e4d8f54f48ef179a39 | |
parent | 2041a1c02cbb2f0b086b5b00c177c9c6b38a9851 (diff) | |
parent | 72959ebc2f300f3b2ccb7ae2aae9f199e611dfb6 (diff) | |
download | rack-bf0e41dc79bd0e7ca21bc077f122ed446e2de03c.tar.gz |
Merge pull request #1453 from rack/rm_to_ary_from_response
Remove `to_ary` from Response
-rw-r--r-- | lib/rack/body_proxy.rb | 5 | ||||
-rw-r--r-- | lib/rack/response.rb | 3 | ||||
-rw-r--r-- | test/spec_body_proxy.rb | 4 | ||||
-rw-r--r-- | test/spec_response.rb | 4 |
4 files changed, 5 insertions, 11 deletions
diff --git a/lib/rack/body_proxy.rb b/lib/rack/body_proxy.rb index 15e4a84f..cb161980 100644 --- a/lib/rack/body_proxy.rb +++ b/lib/rack/body_proxy.rb @@ -9,10 +9,6 @@ module Rack end def respond_to?(method_name, include_all = false) - case method_name - when :to_ary, 'to_ary' - return false - end super or @body.respond_to?(method_name, include_all) end @@ -39,7 +35,6 @@ module Rack end def method_missing(method_name, *args, &block) - super if :to_ary == method_name @body.__send__(method_name, *args, &block) end end diff --git a/lib/rack/response.rb b/lib/rack/response.rb index 58f9e5d6..f39848cc 100644 --- a/lib/rack/response.rb +++ b/lib/rack/response.rb @@ -72,11 +72,10 @@ module Rack close [status.to_i, header, []] else - [status.to_i, header, BodyProxy.new(self){}] + [status.to_i, header, self] end end alias to_a finish # For *response - alias to_ary finish # For implicit-splat on Ruby 1.9.2 def each(&callback) @body.each(&callback) diff --git a/test/spec_body_proxy.rb b/test/spec_body_proxy.rb index 6be79f8b..d3853e1e 100644 --- a/test/spec_body_proxy.rb +++ b/test/spec_body_proxy.rb @@ -63,8 +63,8 @@ describe Rack::BodyProxy do body.respond_to?(:to_ary).must_equal true proxy = Rack::BodyProxy.new(body) { } - proxy.respond_to?(:to_ary).must_equal false - proxy.respond_to?("to_ary").must_equal false + x = [proxy] + assert_equal x, x.flatten end it 'not close more than one time' do diff --git a/test/spec_response.rb b/test/spec_response.rb index 3cd56664..ff7cba6f 100644 --- a/test/spec_response.rb +++ b/test/spec_response.rb @@ -466,8 +466,8 @@ describe Rack::Response do it "wraps the body from #to_ary to prevent infinite loops" do res = Rack::Response.new - res.finish.last.wont_respond_to(:to_ary) - lambda { res.finish.last.to_ary }.must_raise NoMethodError + x = res.finish + assert_equal x, x.flatten end end |