Skip to content

Commit

Permalink
Fix usage of inherited Sinatra::Base classes keyword arguments
Browse files Browse the repository at this point in the history
Using keyword arguments on inherited classes from Sinatra::Base breaks
with ArgumentError: wrong number of arguments (given X, expected 0).

This commit fixes the usage of it on Ruby3 by allowing the method to
accept both positional and keyword arguments.
  • Loading branch information
duduribeiro committed Dec 17, 2020
1 parent 238dd2b commit 64347b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -20,6 +20,7 @@ rvm:
- 2.5.8
- 2.6.6
- 2.7.1
- 3.0.0-preview1
- jruby-9.2.12.0

script: ./.travis.sh
Expand All @@ -28,6 +29,7 @@ matrix:
allow_failures:
- rvm: 2.6.6
- rvm: jruby-9.2.12.0
- rvm: 3.0.0-preview1

notifications:
slack:
Expand Down
4 changes: 2 additions & 2 deletions lib/sinatra/base.rb
Expand Up @@ -1522,8 +1522,8 @@ def prototype
# Create a new instance of the class fronted by its middleware
# pipeline. The object is guaranteed to respond to #call but may not be
# an instance of the class new was called on.
def new(*args, &bk)
instance = new!(*args, &bk)
def new(*args, **kwargs, &bk)
instance = kwargs.length > 0 ? new!(**kwargs, &bk) : new!(*args, &bk)
Wrapper.new(build(instance).to_app, instance)
end

Expand Down

0 comments on commit 64347b0

Please sign in to comment.