Skip to content

Commit

Permalink
Merge pull request #1684 from andrewtblake/master
Browse files Browse the repository at this point in the history
Fix Delegator to pass keyword arguments for Ruby 3.0
  • Loading branch information
namusyaka committed Apr 17, 2021
2 parents cf40452 + e767648 commit ac5404d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/sinatra/base.rb
Expand Up @@ -1947,6 +1947,8 @@ def self.delegate(*methods)
return super(*args, &block) if respond_to? method_name
Delegator.target.send(method_name, *args, &block)
end
# ensure keyword argument passing is compatible with ruby >= 2.7
ruby2_keywords(method_name) if respond_to?(:ruby2_keywords, true)
private method_name
end
end
Expand Down
11 changes: 11 additions & 0 deletions test/delegator_test.rb
Expand Up @@ -88,6 +88,17 @@ def target
assert_equal '', response.body
end

it "delegates before with keyword arguments correctly" do
delegation_app do
set(:foo) do |something|
something
end
before(foo: 'bar') do
:nothing
end
end
end

it "registers extensions with the delegation target" do
app, mixin = mirror, Module.new
Sinatra.register mixin
Expand Down

0 comments on commit ac5404d

Please sign in to comment.