-
Notifications
You must be signed in to change notification settings - Fork 4
/
background.feature_test.go
79 lines (57 loc) · 1.73 KB
/
background.feature_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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package examples_test
import (
"testing"
"github.com/hedhyw/gherkingen/v2/pkg/bdd"
)
func TestMultipleSiteSupport(t *testing.T) {
f := bdd.NewFeature(t, "Multiple site support")
/*
Only blog owners can post to a blog, except administrators,
who can post to all blogs.
*/
background := func(t *testing.T, f *bdd.Feature) interface{} {
/* TODO: Feel free to modify return value(s). */
f.Given("a global administrator named \"Greg\"", func() {
})
f.And("a blog named \"Greg's anti-tax rants\"", func() {
})
f.And("a customer named \"Dr. Bill\"", func() {
})
f.And("a blog named \"Expensive Therapy\" owned by \"Dr. Bill\"", func() {
})
return nil
}
f.Scenario("Dr. Bill posts to his own blog", func(t *testing.T, f *bdd.Feature) {
f.Given("I am logged in as Dr. Bill", func() {
_ = background(t, f)
})
f.When("I try to post to \"Expensive Therapy\"", func() {
_ = background(t, f)
})
f.Then("I should see \"Your article was published.\"", func() {
_ = background(t, f)
})
})
f.Scenario("Dr. Bill tries to post to somebody else's blog, and fails", func(t *testing.T, f *bdd.Feature) {
f.Given("I am logged in as Dr. Bill", func() {
_ = background(t, f)
})
f.When("I try to post to \"Greg's anti-tax rants\"", func() {
_ = background(t, f)
})
f.Then("I should see \"Hey! That's not your blog!\"", func() {
_ = background(t, f)
})
})
f.Scenario("Greg posts to a client's blog", func(t *testing.T, f *bdd.Feature) {
f.Given("I am logged in as Greg", func() {
_ = background(t, f)
})
f.When("I try to post to \"Expensive Therapy\"", func() {
_ = background(t, f)
})
f.Then("I should see \"Your article was published.\"", func() {
_ = background(t, f)
})
})
}