Sha256: 92ea70a56a71670745152f545ef4fa236a578ee9b59843654a96f525a3d7a840

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

FactoryBot.define do
  factory :job_offer, :class => ::JobOffer do
    transient do
      my_transient_attribute { nil }
    end

    trait :tempting_job_offer do
      transient do
        other_transient_attribute { nil }
      end
    end
    trait :risky
    trait :lucrative
  end

  factory :user, :class => User do
    transient do
      movie { nil }
      film { nil }
    end

    after(:build) do |user, evaluator|
      if user.reviewed_movies.blank? && (evaluator.movie || evaluator.film)
        user.reviewed_movies << (evaluator.movie || evaluator.film)
      end
    end
  end

  factory :movie, :class => Movie do
    transient do
      user { nil }
      user_id { nil }
    end

    after(:build) do |movie, evaluator|
      movie.reviewer = evaluator.user if evaluator.user
      movie.reviewer_id = evaluator.user_id if evaluator.user_id
    end

    trait :parent_movie_trait

    factory :subgenre_movie, traits: [:parent_movie_trait]
  end
  factory :opera, :class => Opera
  factory :payment, :class => Payment
  factory :uuid_user, :class => UuidUser
  factory :film, :class => Movie
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cucumber_factory-2.5.0 spec/support/factories/factories.rb