trailblazer / rspec-cells

Spec your Cells.
http://cells.rubyforge.org
MIT License
62 stars 48 forks source link

Support ruby 3 #95

Closed petar-lazarov closed 3 years ago

petar-lazarov commented 3 years ago

The delegation in #method_missing is breaking with ruby 3 because for ruby 3 the delegation should explicitly delegate both positional and keyword arguments. I'm using ruby2_keywords to keep the old behavior until the support of ruby < 3 is dropped.

The method ruby2_keywords is present only in rubies that are >= 2.7 and that is why the check if respond_to?(:ruby2_keywords, true) is needed.

apotonick commented 3 years ago

Thanks! Wouldn't it be better, though, to change it properly here?

def method_missing(method, *args, **kws, &block)
        # Send the route helpers to the application router.
        if route_defined?(method)
          controller.send(method, *args, **kws, &block)
petar-lazarov commented 3 years ago

Thanks! Wouldn't it be better, though, to change it properly here?

I was not sure if it is going to work for older versions of ruby and also with the call to super but I guess it is going to be OK. Just to be sure, I ran my cells tests with the new code on ruby 2.6 and ruby 3 and they are executing fine.

apotonick commented 3 years ago

Maybe we should limit the new version to Ruby >= 2.7.

apotonick commented 3 years ago

@yogeshjain999 Could you kindly add CI? :heart:

apotonick commented 3 years ago

Haha, sorry @yogeshjain999 I just realized there's CI set up! :beers:

apotonick commented 3 years ago

Successfully registered gem: rspec-cells (0.3.6) :rock: