From 0da5fc6bcb7f031724f3a0b3035ee45cbb91ab6a Mon Sep 17 00:00:00 2001 From: Softonik Date: Sat, 19 Aug 2023 00:52:38 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20snippet=20=D1=82=D0=B5=D1=81=D1=82=D1=8B?= =?UTF-8?q?=20=D0=B8=20=D1=81=D0=B0=D0=BC=20=D0=B1=D0=BE=D0=BB=D0=B5=D0=B5?= =?UTF-8?q?=20=D1=83=D0=B4=D0=BE=D0=B1=D0=BD=D1=8B=D0=B9=20=D0=B2=D0=B8?= =?UTF-8?q?=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- features/snippets.feature | 98 +++++++++---------- internal/formatters/undefined_snippets_gen.go | 4 +- 2 files changed, 46 insertions(+), 56 deletions(-) diff --git a/features/snippets.feature b/features/snippets.feature index 05b9c3b..2188c55 100644 --- a/features/snippets.feature +++ b/features/snippets.feature @@ -20,16 +20,15 @@ Feature: undefined step snippets """ And the undefined step snippets should be: """ - func iSendRequestTo(arg1, arg2 string) { - } + func InitializeScenario(ctx *godog.ScenarioContext) {} + // --- - func theResponseCodeShouldBe(arg1 int) { - } - func InitializeScenario(ctx *godog.ScenarioContext) { - ctx.Step(`^I send "([^"]*)" request to "([^"]*)"$`, iSendRequestTo) - ctx.Step(`^the response code should be (\d+)$`, theResponseCodeShouldBe) - } + func iSendRequestTo(arg1, arg2 string) { } + func theResponseCodeShouldBe(arg1 int) { } + + ctx.Step(`^I send "([^"]*)" request to "([^"]*)"$`, iSendRequestTo) + ctx.Step(`^the response code should be (\d+)$`, theResponseCodeShouldBe) """ Scenario: should generate snippets with more arguments @@ -50,20 +49,17 @@ Feature: undefined step snippets When I run feature suite Then the undefined step snippets should be: """ - func iSendRequestToWith(arg1, arg2 string, arg3 *godog.Table) { - } + func InitializeScenario(ctx *godog.ScenarioContext) {} + // --- - func theResponseCodeShouldBeAndHeaderShouldBe(arg1 int, arg2, arg3 string) { - } - func theResponseBodyShouldBe(arg1 *godog.DocString) { - } + func iSendRequestToWith(arg1, arg2 string, arg3 *godog.Table) { } + func theResponseCodeShouldBeAndHeaderShouldBe(arg1 int, arg2, arg3 string) { } + func theResponseBodyShouldBe(arg1 *godog.DocString) { } - func InitializeScenario(ctx *godog.ScenarioContext) { - ctx.Step(`^I send "([^"]*)" request to "([^"]*)" with:$`, iSendRequestToWith) - ctx.Step(`^the response code should be (\d+) and header "([^"]*)" should be "([^"]*)"$`, theResponseCodeShouldBeAndHeaderShouldBe) - ctx.Step(`^the response body should be:$`, theResponseBodyShouldBe) - } + ctx.Step(`^I send "([^"]*)" request to "([^"]*)" with:$`, iSendRequestToWith) + ctx.Step(`^the response code should be (\d+) and header "([^"]*)" should be "([^"]*)"$`, theResponseCodeShouldBeAndHeaderShouldBe) + ctx.Step(`^the response body should be:$`, theResponseBodyShouldBe) """ Scenario: should handle escaped symbols @@ -83,16 +79,15 @@ Feature: undefined step snippets """ And the undefined step snippets should be: """ - func iPullFromGithubcom() { - } + func InitializeScenario(ctx *godog.ScenarioContext) {} + // --- - func theProjectShouldBeThere() { - } - func InitializeScenario(ctx *godog.ScenarioContext) { - ctx.Step(`^I pull from github\.com$`, iPullFromGithubcom) - ctx.Step(`^the project should be there$`, theProjectShouldBeThere) - } + func iPullFromGithubcom() { } + func theProjectShouldBeThere() { } + + ctx.Step(`^I pull from github\.com$`, iPullFromGithubcom) + ctx.Step(`^the project should be there$`, theProjectShouldBeThere) """ Scenario: should handle string argument followed by comma @@ -107,16 +102,15 @@ Feature: undefined step snippets When I run feature suite And the undefined step snippets should be: """ - func thereIsAWhichCosts(arg1 string, arg2 int) { - } + func InitializeScenario(ctx *godog.ScenarioContext) {} + // --- - func iAddTheToTheBasket(arg1 string) { - } - func InitializeScenario(ctx *godog.ScenarioContext) { - ctx.Step(`^there is a "([^"]*)", which costs £(\d+)$`, thereIsAWhichCosts) - ctx.Step(`^I add the "([^"]*)" to the basket$`, iAddTheToTheBasket) - } + func thereIsAWhichCosts(arg1 string, arg2 int) { } + func iAddTheToTheBasket(arg1 string) { } + + ctx.Step(`^there is a "([^"]*)", which costs £(\d+)$`, thereIsAWhichCosts) + ctx.Step(`^I add the "([^"]*)" to the basket$`, iAddTheToTheBasket) """ Scenario: should handle arguments in the beggining or end of the step @@ -131,16 +125,15 @@ Feature: undefined step snippets When I run feature suite And the undefined step snippets should be: """ - func whichCosts(arg1 string, arg2 int) { - } + func InitializeScenario(ctx *godog.ScenarioContext) {} + // --- - func godogs(arg1 int) { - } - func InitializeScenario(ctx *godog.ScenarioContext) { - ctx.Step(`^"([^"]*)", which costs £(\d+)$`, whichCosts) - ctx.Step(`^(\d+) godogs$`, godogs) - } + func whichCosts(arg1 string, arg2 int) { } + func godogs(arg1 int) { } + + ctx.Step(`^"([^"]*)", which costs £(\d+)$`, whichCosts) + ctx.Step(`^(\d+) godogs$`, godogs) """ Scenario: should generate snippets in russian @@ -167,18 +160,15 @@ Feature: undefined step snippets """ And the undefined step snippets should be: """ - func чтото() { - } + func InitializeScenario(ctx *godog.ScenarioContext) {} + // --- - func яДелаюЕщёЧтотоParam(param1 string, arg1, arg2 int, param2, параметр3, arg3, data string) { - } - func получаетсяЕщёБолееЧтото() { - } + func чтото() { } + func яДелаюЕщёЧтотоParam(param1 string, arg1, arg2 int, param2, параметр3, arg3, data string) { } + func получаетсяЕщёБолееЧтото() { } - func InitializeScenario(ctx *godog.ScenarioContext) { - ctx.Step(`^что-то$`, чтото) - ctx.Step(`^я делаю ещё что-то "([^"]*)", (\d+), (\d+), param="([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)"$`, яДелаюЕщёЧтотоParam) - ctx.Step(`^получается ещё более что-то$`, получаетсяЕщёБолееЧтото) - } + ctx.Step(`^что-то$`, чтото) + ctx.Step(`^я делаю ещё что-то "([^"]*)", (\d+), (\d+), param="([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)"$`, яДелаюЕщёЧтотоParam) + ctx.Step(`^получается ещё более что-то$`, получаетсяЕщёБолееЧтото) """ diff --git a/internal/formatters/undefined_snippets_gen.go b/internal/formatters/undefined_snippets_gen.go index e890b27..c3ea9d9 100644 --- a/internal/formatters/undefined_snippets_gen.go +++ b/internal/formatters/undefined_snippets_gen.go @@ -29,8 +29,8 @@ var undefinedSnippetsTpl = template.Must(template.New("snippets").Funcs(snippetH {{ range . }}func {{ .Method }}({{ .Args }}) { } -{{end}} -{{ range . }} ctx.Step({{ backticked .Expr }}, {{ .Method }}){{end}} +{{end}}{{ range . }} + ctx.Step({{ backticked .Expr }}, {{ .Method }}){{end}} `)) type undefinedSnippet struct {