Skip to content

Ruby 3 compatibility #677

@swiknaba

Description

@swiknaba

Have there been any efforts already on getting this gem ready for Ruby 3?

this kind of magic: https://github.com/DatabaseCleaner/database_cleaner/blob/master/lib/database_cleaner/cleaner.rb#L43

    def strategy=(args)
      strategy, *strategy_args = args

won't work in Ruby 3, I've seen quite some usage of this pattern.

Also, the redis and the active_record sub-gems use kwargs vs. options-hashes differently, see:

options hash: https://github.com/DatabaseCleaner/database_cleaner-active_record/blob/master/lib/database_cleaner/active_record/truncation.rb#L8

class Truncation < Base
  def initialize(opts={})

kwargs: https://github.com/DatabaseCleaner/database_cleaner-redis/blob/master/lib/database_cleaner/redis/deletion.rb#L6

    class Deletion < Strategy
      def initialize only: [], except: []

which will make it harder to upgrade the database gem family.

So probably as a first step, we should harmonize all sub-gems to use the same way of passing options around, either as a hash or using keyword arguments. From there we can tinker further.

I've tried it quickly locally and run into too many issues to push a draft PR. I might find more time on one of the next weekends though. -> hence the question, if there is already any PR/fork that started working on Ruby 3 compatibility.

As always, thanks for the gems 🙂

=> Specs are passing for Postgresql, MySQL, SQLlite locally, however, when I use

DatabaseCleaner.strategy = :deletion, { except: %i[not_you also_not_you blubb] }

in one of my projects, strategy= fails with the Ruby 3 kwargs/hash error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions