Sha256: 4354c01a3931a529824bbdb57a4ce942a11a771a620097d5d3456ede4dc90f30

Contents?: true

Size: 387 Bytes

Versions: 1

Compression:

Stored size: 387 Bytes

Contents

FactoryGirl.define do
  factory :author do
    name { Faker::Name.name }
  end

  [:post, :comment].each do |type|
    factory type do
      transient { author nil }

      before(:create) do |record, evaluator|
        if evaluator.author
          author = Author.find_or_create_by(name: evaluator.author)
          record.author_id = author.id
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
repor-0.1.0 spec/factories/factories.rb