nesquena / rabl

General ruby templating with json, bson, xml, plist and msgpack support
http://blog.codepath.com/2011/06/27/building-a-platform-api-on-rails/
MIT License
3.64k stars 333 forks source link

Fix `ArgumentError` when there are no keyword arguments (Ruby < 2.7) #759

Closed sylvain-8422 closed 2 years ago

sylvain-8422 commented 2 years ago

Calling helper methods that are not meant to receive keyword arguments fails with RABL version 0.16.0 and using Ruby < 2.7.

Without the fix, the two new assertions fail.

Here a simple IRB session demonstrating the source of the problem (using Ruby 2.6.10) :

object = ::Object.new

def object.method
  :value
end

object.__send__(:method, **{})
=> :value

kwargs = {}

object.__send__(:method, **kwargs)
ArgumentError (wrong number of arguments (given 1, expected 0))

The fix would be much appreciated, as otherwise we would have to restrict RABL to < 0.16.0.

nesquena commented 2 years ago

Thanks!

nesquena commented 2 years ago

Pushed as rabl 0.16.1, thanks again!