-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpaprika2markdown_test.go
57 lines (52 loc) · 1.61 KB
/
paprika2markdown_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main_test
import (
"io/ioutil"
"path/filepath"
"text/template"
. "github.com/compybara/paprika2markdown/recipe"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Paprika2markdown", func() {
var (
templateFile string
templateFileFullPath string
recipe Recipe
)
BeforeEach(func() {
templateFile = "./templates/template.md"
templateFileFullPath, _ = filepath.Abs(templateFile)
recipe = Recipe{
Name: "Chicken Nuggets",
Source: "The back of the packet",
PrepTime: "1 minute",
CookTime: "20 minutes",
Servings: []int{1, 2},
Categories: []string{"Frozen food", "Lazy dinners"},
Notes: "How to heat up frozen chicken nuggets.",
Ingredients: []string{"One packet chicken nuggets", "(1/4 cup) Ketchup"},
Directions: []string{"Preheat oven to 400 Degrees",
"Open packet",
"Put nuggets onto a pan",
"Place in oven",
"Bake for 20 minutes",
"Put onto a plate with your bare hands",
"Nurse burns caused by impatience",
"Put ketchup onto plate in a pile next to the nuggets"},
}
})
Describe("Default template", func() {
Context("should load from file", func() {
It("should exist", func() {
Expect(templateFileFullPath).To(BeAnExistingFile())
})
It("should parse and execute", func() {
recipeTemplate, parseErr := template.ParseFiles(templateFileFullPath)
Ω(parseErr).ShouldNot(HaveOccurred())
// Make sure it executes and just discard the output.
execErr := recipeTemplate.Execute(ioutil.Discard, recipe)
Ω(execErr).ShouldNot(HaveOccurred())
})
})
})
})