Skip to content

"Class" loaded more than once? #1639

@stevenou

Description

@stevenou

Description

Changes introduced in #1610 are causing "the class" to load more than once. Specifically, the change to namespace.set(name, Class.new(parent)).

I encountered this because searchkick now raises RuntimeError: Only call searchkick once per model. I am running searchkick inside def inherited(subclass) and the changes are causing that to run again, thus raising an error.

Reproduction Steps

Not too sure what reproduction steps are relevant. At this point I don't understand the issue well enough to even know if it should be considered a bug or not.

Expected behavior

"The class" isn't loaded more than once during testing. This is the behavior in version <= 6.1.0.

Actual behavior

In version 6.2.0, the code inside def inherited(subclass) runs more than once for the "same" class, presumably because there is now another anonymous class that inherits from it.

System configuration

shoulda_matchers version: 6.2.0
rails version: 7.1.3.4
ruby version: 3.3.0

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