Этот коммит содержится в:
Fredrik Lönnblad 2020-03-10 09:39:59 -03:00
родитель 0ab3e09327
коммит f045623fcf
2 изменённых файлов: 15 добавлений и 15 удалений

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

@ -312,14 +312,14 @@ func (f *pretty) printStep(result *stepResult) {
}
scenarioHeaderLength, maxLength := f.scenarioLengths(result.owner.AstNodeIds[0])
stepLength := f.lengthPickleStep(astStep.Keyword, astStep.Text)
stepLength := f.lengthPickleStep(astStep.Keyword, result.step.Text)
firstExecutedScenarioStep := len(f.lastFeature().lastPickleResult().stepResults) == backgroundSteps+1
if !astBackgroundStep && firstExecutedScenarioStep {
f.printScenarioHeader(astScenario, maxLength-scenarioHeaderLength)
}
text := s(f.indent*2) + result.status.clr()(strings.TrimSpace(astStep.Keyword)) + " " + result.status.clr()(astStep.Text)
text := s(f.indent*2) + result.status.clr()(strings.TrimSpace(astStep.Keyword)) + " " + result.status.clr()(result.step.Text)
if result.def != nil {
text += s(maxLength - stepLength + 1)
text += blackb("# " + result.def.definitionID())

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

@ -107,31 +107,31 @@ func SuiteContext(s *Suite, additionalContextInitializers ...func(suite *Suite))
s.BeforeStep(c.inject)
}
func (s *suiteContext) inject(step *gherkin.Step) {
func (s *suiteContext) inject(step *messages.Pickle_PickleStep) {
if !s.allowInjection {
return
}
step.Text = injectAll(step.Text)
args := step.Argument
if args != nil {
switch arg := args.(type) {
case *gherkin.DataTable:
for i := 0; i < len(arg.Rows); i++ {
for n, cell := range arg.Rows[i].Cells {
arg.Rows[i].Cells[n].Value = injectAll(cell.Value)
}
if table := step.Argument.GetDataTable(); table != nil {
for i := 0; i < len(table.Rows); i++ {
for n, cell := range table.Rows[i].Cells {
table.Rows[i].Cells[n].Value = injectAll(cell.Value)
}
case *gherkin.DocString:
arg.Content = injectAll(arg.Content)
}
}
if doc := step.Argument.GetDocString(); doc != nil {
doc.Content = injectAll(doc.Content)
}
}
func injectAll(inTo string) string {
func injectAll(src string) string {
re := regexp.MustCompile(`{{[^{}]+}}`)
return re.ReplaceAllStringFunc(
inTo,
src,
func(key string) string {
injectRegex := regexp.MustCompile(`^{{.+}}$`)
if injectRegex.MatchString(key) {