Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Delegator to pass keyword arguments for Ruby 3.0 #1684

Merged
merged 4 commits into from Apr 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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