parsley/spec/models/nutrition_data_spec.rb

57 lines
1.1 KiB
Ruby

require 'rails_helper'
RSpec.describe NutritionData, type: :model do
let(:rec1_ingredients) do
[
RecipeIngredient.new({
quantity: '100',
units: 'g',
sort_order: 1,
food: create(:food, kcal: 10, protein: 2)
}),
RecipeIngredient.new({
quantity: '100',
units: 'g',
sort_order: 2,
food: create(:food, kcal: 10, lipids: 2)
})
]
end
let(:recipe1) do
create(:recipe, yields: '500 g').tap do |r|
r.recipe_ingredients = rec1_ingredients
end
end
let(:rec2_ingredients) do
[
RecipeIngredient.new({
quantity: '100',
units: 'g',
sort_order: 1,
recipe_as_ingredient: recipe1
}),
RecipeIngredient.new({
quantity: '100',
units: 'g',
sort_order: 2,
food: create(:food, kcal: 10, lipids: 2)
})
]
end
let(:recipe2) do
create(:recipe, yields: '500 g').tap do |r|
r.recipe_ingredients = rec2_ingredients
end
end
it 'runs' do
n = recipe2.nutrition_data
end
end