Sha256: 0e536b75d598b34751913035465496f166559bc598938de222a2855e6da81033

Contents?: true

Size: 919 Bytes

Versions: 97

Compression:

Stored size: 919 Bytes

Contents

# frozen_string_literal: true

FactoryBot.define do
  factory :pd_patient, class: "Renalware::PD::Patient", parent: :patient do
    trait :with_pd_modality do
      after(:create) do |instance|
        # This a rather clumsy approach to trying to re-use the set_modality helper
        # in PatientsSpecHelper; we can't include the module here so I am creating
        # a contrived class so I can mix in PatientsSpecHelper.
        # Other options here
        # https://github.com/thoughtbot/factory_bot/issues/564#issuecomment-157669866
        class ModalityMaker
          include PatientsSpecHelper

          def call(patient)
            set_modality(
              patient: patient,
              modality_description: FactoryBot.create(:pd_modality_description),
              by: patient.created_by
            )
          end
        end
        ModalityMaker.new.call(instance)
      end
    end
  end
end

Version data entries

97 entries across 97 versions & 1 rubygems

Version Path
renalware-core-2.1.1 spec/factories/pd/patients.rb
renalware-core-2.1.0 spec/factories/pd/patients.rb
renalware-core-2.0.167 spec/factories/pd/patients.rb
renalware-core-2.0.166 spec/factories/pd/patients.rb
renalware-core-2.0.165 spec/factories/pd/patients.rb
renalware-core-2.0.164 spec/factories/pd/patients.rb
renalware-core-2.0.163 spec/factories/pd/patients.rb
renalware-core-2.0.162 spec/factories/pd/patients.rb
renalware-core-2.0.161 spec/factories/pd/patients.rb
renalware-core-2.0.160 spec/factories/pd/patients.rb
renalware-core-2.0.159 spec/factories/pd/patients.rb
renalware-core-2.0.158 spec/factories/pd/patients.rb
renalware-core-2.0.157 spec/factories/pd/patients.rb
renalware-core-2.0.156 spec/factories/pd/patients.rb
renalware-core-2.0.155 spec/factories/pd/patients.rb
renalware-core-2.0.153 spec/factories/pd/patients.rb
renalware-core-2.0.152 spec/factories/pd/patients.rb
renalware-core-2.0.151 spec/factories/pd/patients.rb
renalware-core-2.0.149 spec/factories/pd/patients.rb
renalware-core-2.0.148 spec/factories/pd/patients.rb