diff --git a/features/snippets.feature b/features/snippets.feature index e5119f7..2e3f39e 100644 --- a/features/snippets.feature +++ b/features/snippets.feature @@ -153,3 +153,43 @@ Feature: undefined step snippets ctx.Step(`^"([^"]*)", which costs £(\d+)$`, whichCosts) } """ + + Scenario: should generate snippets in russian + Given a feature "undefined.feature" file: + """ + # language: ru + + Функционал: суперфича + + Сценарий: делает что-то полезное + Дано что-то + Когда я делаю ещё что-то + То получается ещё более что-то + """ + When I run feature suite + Then the following steps should be undefined: + """ + получается ещё более что-то + что-то + я делаю ещё что-то + """ + And the undefined step snippets should be: + """ + func получаетсяЕщёБолееЧтото() error { + return godog.ErrPending + } + + func чтото() error { + return godog.ErrPending + } + + func яДелаюЕщёЧтото() error { + return godog.ErrPending + } + + func InitializeScenario(ctx *godog.ScenarioContext) { + ctx.Step(`^получается ещё более что-то$`, получаетсяЕщёБолееЧтото) + ctx.Step(`^что-то$`, чтото) + ctx.Step(`^я делаю ещё что-то$`, яДелаюЕщёЧтото) + } + """ diff --git a/internal/formatters/fmt_base.go b/internal/formatters/fmt_base.go index c95a97f..b7e5394 100644 --- a/internal/formatters/fmt_base.go +++ b/internal/formatters/fmt_base.go @@ -228,7 +228,8 @@ func (f *Base) Snippets() string { case i != 0: w = strings.Title(w) case len(w) > 0: - w = string(unicode.ToLower(rune(w[0]))) + w[1:] + r := []rune(w) + w = string(unicode.ToLower(r[0])) + string(r[1:]) } words = append(words, w) } diff --git a/internal/formatters/undefined_snippets_gen.go b/internal/formatters/undefined_snippets_gen.go index 5b5721e..7c4a7c5 100644 --- a/internal/formatters/undefined_snippets_gen.go +++ b/internal/formatters/undefined_snippets_gen.go @@ -13,7 +13,7 @@ import ( // some snippet formatting regexps var snippetExprCleanup = regexp.MustCompile("([\\/\\[\\]\\(\\)\\\\^\\$\\.\\|\\?\\*\\+\\'])") var snippetExprQuoted = regexp.MustCompile("(\\W|^)\"(?:[^\"]*)\"(\\W|$)") -var snippetMethodName = regexp.MustCompile("[^a-zA-Z\\_\\ ]") +var snippetMethodName = regexp.MustCompile("[^a-zA-Zа-яА-ЯёЁ\\_\\ ]") var snippetNumbers = regexp.MustCompile("(\\d+)") var snippetHelperFuncs = template.FuncMap{