malcoauri
malcoauri

Reputation: 12209

FactoryGirl with params by default

There is the following code:

  factory :item do
    name        'Some name'
    description 'Some description'
    cost        100
    cooking_time 10
    menu
  end

This code sets up cooking_time as a constant value, but how can I pass param for this param with default value (10)? Thanks

Upvotes: 0

Views: 135

Answers (2)

Muhamamd Awais
Muhamamd Awais

Reputation: 2385

create(:item, cooking_time: 20)

For more inforamation please go through Factory Girl Documentation

Upvotes: 1

steakchaser
steakchaser

Reputation: 5249

You just override the attribute when you use the factory in your test:

create(:item, cooking_time: 20)

Upvotes: 0

Related Questions