require godog contexts to be exported

Этот коммит содержится в:
gedi 2016-06-14 16:33:13 +03:00
родитель 2772b1df34
коммит 4610466f82
7 изменённых файлов: 20 добавлений и 9 удалений

Просмотреть файл

@ -157,7 +157,7 @@ func thereShouldBeRemaining(remaining int) error {
return nil
}
func featureContext(s *godog.Suite) {
func FeatureContext(s *godog.Suite) {
s.Step(`^there are (\d+) godogs$`, thereAreGodogs)
s.Step(`^I eat (\d+)$`, iEat)
s.Step(`^there should be (\d+) remaining$`, thereShouldBeRemaining)

Просмотреть файл

@ -12,6 +12,7 @@ import (
"path/filepath"
"strings"
"text/template"
"unicode"
)
var godogImportPath = "github.com/DATA-DOG/godog"
@ -215,5 +216,16 @@ func processPackageTestFiles(packs ...[]string) ([]string, error) {
ctxs = append(ctxs, astContexts(node)...)
}
}
var failed []string
for _, ctx := range ctxs {
runes := []rune(ctx)
if unicode.IsLower(runes[0]) {
expected := append([]rune{unicode.ToUpper(runes[0])}, runes[1:]...)
failed = append(failed, fmt.Sprintf("%s - should be: %s", ctx, string(expected)))
}
}
if len(failed) > 0 {
return ctxs, fmt.Errorf("godog contexts must be exported:\n\t%s", strings.Join(failed, "\n\t"))
}
return ctxs, nil
}

Просмотреть файл

@ -67,7 +67,7 @@ func (a *apiFeature) theResponseShouldMatchJSON(body *gherkin.DocString) (err er
return
}
func featureContext(s *godog.Suite) {
func FeatureContext(s *godog.Suite) {
api := &apiFeature{}
s.BeforeScenario(api.resetResponse)

Просмотреть файл

@ -8,7 +8,6 @@ import (
"net/http/httptest"
"strings"
"github.com/DATA-DOG/go-txdb"
"github.com/DATA-DOG/godog"
"github.com/DATA-DOG/godog/gherkin"
)
@ -118,7 +117,7 @@ func (a *apiFeature) thereAreUsers(users *gherkin.DataTable) error {
return nil
}
func featureContext(s *godog.Suite) {
func FeatureContext(s *godog.Suite) {
api := &apiFeature{}
s.BeforeScenario(api.resetResponse)

Просмотреть файл

@ -26,7 +26,7 @@ func thereShouldBeRemaining(remaining int) error {
return nil
}
func featureContext(s *godog.Suite) {
func FeatureContext(s *godog.Suite) {
s.Step(`^there are (\d+) godogs$`, thereAreGodogs)
s.Step(`^I eat (\d+)$`, iEat)
s.Step(`^there should be (\d+) remaining$`, thereShouldBeRemaining)

Просмотреть файл

@ -28,7 +28,7 @@ Feature: undefined step snippets
return godog.ErrPending
}
func featureContext(s *godog.Suite) {
func FeatureContext(s *godog.Suite) {
s.Step(`^I send "([^"]*)" request to "([^"]*)"$`, iSendRequestTo)
s.Step(`^the response code should be (\d+)$`, theResponseCodeShouldBe)
}
@ -56,7 +56,7 @@ Feature: undefined step snippets
return godog.ErrPending
}
func featureContext(s *godog.Suite) {
func FeatureContext(s *godog.Suite) {
s.Step(`^I send "([^"]*)" request to "([^"]*)" with:$`, iSendRequestToWith)
s.Step(`^the response code should be (\d+) and header "([^"]*)" should be "([^"]*)"$`, theResponseCodeShouldBeAndHeaderShouldBe)
}
@ -87,7 +87,7 @@ Feature: undefined step snippets
return godog.ErrPending
}
func featureContext(s *godog.Suite) {
func FeatureContext(s *godog.Suite) {
s.Step(`^I pull from github\.com$`, iPullFromGithubcom)
s.Step(`^the project should be there$`, theProjectShouldBeThere)
}

2
fmt.go
Просмотреть файл

@ -30,7 +30,7 @@ var undefinedSnippetsTpl = template.Must(template.New("snippets").Funcs(snippetH
return godog.ErrPending
}
{{end}}func featureContext(s *godog.Suite) { {{ range . }}
{{end}}func FeatureContext(s *godog.Suite) { {{ range . }}
s.Step({{ backticked .Expr }}, {{ .Method }}){{end}}
}
`))