From b10470da31cdf518f1a859e5d9b7df5b34e17276 Mon Sep 17 00:00:00 2001 From: gedi Date: Wed, 24 May 2017 16:04:43 +0300 Subject: [PATCH] closes #86 --- features/snippets.feature | 26 ++++++++++++++++++++++++++ fmt.go | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/features/snippets.feature b/features/snippets.feature index 773b2a9..af77def 100644 --- a/features/snippets.feature +++ b/features/snippets.feature @@ -118,3 +118,29 @@ Feature: undefined step snippets s.Step(`^I add the "([^"]*)" to the basket$`, iAddTheToTheBasket) } """ + + Scenario: should handle arguments in the beggining or end of the step + Given a feature "undefined.feature" file: + """ + Feature: undefined + + Scenario: add item to basket + Given "Sith Lord Lightsaber", which costs £5 + And 12 godogs + """ + When I run feature suite + And the undefined step snippets should be: + """ + func whichCosts(arg1 string, arg2 int) error { + return godog.ErrPending + } + + func godogs(arg1 int) error { + return godog.ErrPending + } + + func FeatureContext(s *godog.Suite) { + s.Step(`^"([^"]*)", which costs £(\d+)$`, whichCosts) + s.Step(`^(\d+) godogs$`, godogs) + } + """ diff --git a/fmt.go b/fmt.go index a51a47f..d694b25 100644 --- a/fmt.go +++ b/fmt.go @@ -403,7 +403,7 @@ func (f *basefmt) snippets() string { name := snippetNumbers.ReplaceAllString(step, " ") name = snippetExprQuoted.ReplaceAllString(name, " ") - name = snippetMethodName.ReplaceAllString(name, "") + name = strings.TrimSpace(snippetMethodName.ReplaceAllString(name, "")) var words []string for i, w := range strings.Split(name, " ") { if i != 0 {