FactoryBot.define do

  sequence :unique_ndbn do |n|
    n.to_s.rjust(5, '0')
  end

  factory :usda_food do
    long_description { 'Food' }
    short_description { 'Food' }
    ndbn { generate :unique_ndbn }
    water { 1.0 }
    kcal { 101 }
    protein { 1.2 }
    lipid { 3.4 }
    ash { 0 }
    carbohydrates { 3.3 }
    fiber { 1.2 }
    sugar { 10 }
    gram_weight_1 { 200 }
    gram_weight_2 { 100 }
    gram_weight_desc_1 { '1 cup' }
    gram_weight_desc_2 { '1/2 cup' }
    refuse_percent { 3 }
  end

  factory :salted_butter, parent: :usda_food do
    long_description { 'Butter, salted' }
    short_description { 'BUTTER,WITH SALT' }
    water { 15.87 }
    kcal { 717 }
    protein { 0.85 }
    lipid { 81.11 }
    ash { 2.11 }
    carbohydrates { 0.06 }
    fiber { 0 }
    sugar { 0.06 }
    gram_weight_1 { 5.0 }
    gram_weight_2 { 14.2 }
    gram_weight_desc_1 { '1 pat,  (1\" sq, 1/3\" high)' }
    gram_weight_desc_2 { '1 tbsp' }
    refuse_percent { 0 }
  end

end
