# File test/test_tablecloth.rb, line 34 def test_add_ingredient ingredient = TableCloth::Ingredient.new :qty => "1", :item => "sugar", :unit => :kg assert_equal ingredient.class, TableCloth::Ingredient tc = TableCloth::Recipe.new tc.ingredients << ingredient assert_equal tc.ingredients.first, ingredient end
# File test/test_tablecloth.rb, line 44 def test_iteration tc = TableCloth::Recipe.new(:ingredients => "1 kg sugar \n 2kg carrots") assert_equal 2, tc.ingredients.count tc.ingredients.each do |ingredient| assert ingredient.class == TableCloth::Ingredient end end
# File test/test_tablecloth.rb, line 24 def test_multi_line_recipe str = "1 tablespoon salt \n 1/2 cup sugar" tc = TableCloth::Recipe.new :ingredients => str assert_equal tc.ingredients.count, 2 #str = "1 tablespoon salt, 1/2 cup sugar" #tc = TableCloth::Recipe.new :ingredients => str #assert_equal tc.ingredients.count, 2 end
# File test/test_tablecloth.rb, line 16 def test_one_line_recipe str = "1 tablespoon salt" tc = TableCloth::Recipe.new :ingredients => str #should only be one assert_equal tc.ingredients.count, 1 end
# File test/test_tablecloth.rb, line 8 def test_type str = "anything" tc = TableCloth::Recipe.new :ingredients => str #shoudl return an array assert_equal TableCloth::Ingredients, tc.ingredients.class end