diff options
author | Jeremy Evans <code@jeremyevans.net> | 2020-01-30 12:50:56 -0800 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2020-01-30 12:54:41 -0800 |
commit | 4804192aaba4319f8a019043eeed84982c2515e7 (patch) | |
tree | 58eb5af46d35e8650237609244a16149d1b13c25 | |
parent | 06d23735ca8ea82ec1a6abdb1cb9158454a00eb0 (diff) | |
download | rack-4804192aaba4319f8a019043eeed84982c2515e7.tar.gz |
Make BodyProxy correctly delegate keyword arguments on Ruby 2.7+
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | lib/rack/body_proxy.rb | 1 | ||||
-rw-r--r-- | test/spec_body_proxy.rb | 7 |
3 files changed, 9 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index c5f5416e..59a8ba32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ All notable changes to this project will be documented in this file. For info on ### Fixed +- `BodyProxy` correctly delegates keyword arguments to the body object on Ruby 2.7+. ([@jeremyevans](https://github.com/jeremyevans)) - `BodyProxy#method` correctly handles methods delegated to the body object. ([@jeremyevans](https://github.com/jeremyevans)) - `Request#host` and `Request#host_with_port` handle IPv6 addresses correctly. ([@AlexWayfer](https://github.com/AlexWayfer)) - `Lint` checks when response hijacking that `rack.hijack` is called with a valid object. ([@jeremyevans](https://github.com/jeremyevans)) diff --git a/lib/rack/body_proxy.rb b/lib/rack/body_proxy.rb index 12347916..ebb7db39 100644 --- a/lib/rack/body_proxy.rb +++ b/lib/rack/body_proxy.rb @@ -29,5 +29,6 @@ module Rack def method_missing(method_name, *args, &block) @body.__send__(method_name, *args, &block) end + ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true) end end diff --git a/test/spec_body_proxy.rb b/test/spec_body_proxy.rb index fe70d2ef..1199f2f1 100644 --- a/test/spec_body_proxy.rb +++ b/test/spec_body_proxy.rb @@ -63,6 +63,13 @@ describe Rack::BodyProxy do proxy.method(:banana).call.must_equal :pear end + it 'allows calling delegated methods with keywords' do + body = Object.new + def body.banana(foo: nil); foo end + proxy = Rack::BodyProxy.new(body) { } + proxy.banana(foo: 1).must_equal 1 + end + it 'not respond to :to_ary' do body = Object.new.tap { |o| def o.to_ary() end } body.respond_to?(:to_ary).must_equal true |