Skip to content

FactoryBot/FactoryAssociationWithStrategy false positive with keyword argument #73

@jcoyne

Description

@jcoyne
spec/factories/holdings.rb:7:14: C: FactoryBot/FactoryAssociationWithStrategy: Use an implicit, explicit or inline definition instead of hard coding a strategy for setting association within factory.
      item { build(:item, :available, location:) }
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I don't think there is another way to write this given that location references another transient:

FactoryBot.define do
  factory :holding do
    transient do
      location factory: :gre_stacks
      item { build(:item, :available, location:) }
    end
    
    ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions