Ejemplo n.º 1
0
func (self *extractor) handleTable(stepInConcept *parser.Step, step *gauge_messages.Step) {
	stepInConcept.Value += " {}"
	specText := self.fileContent + step.GetTable()
	spec, result := new(parser.SpecParser).Parse(specText, &parser.ConceptDictionary{})
	if !result.Ok {
		self.errors = append(self.errors, result.ParseError)
		return
	}
	stepArgs := []*parser.StepArg{spec.Scenarios[0].Steps[0].Args[0]}
	self.addTableAsParam(step, stepArgs)
	stepInConcept.Args = append(stepInConcept.Args, stepArgs[0])
}
Ejemplo n.º 2
0
func getExtractedConcept(conceptName *gauge_messages.Step, steps []*gauge_messages.Step, content string) (string, string, error) {
	tokens, _ := new(parser.SpecParser).GenerateTokens("* " + conceptName.GetName())
	conceptStep, _ := (&parser.Specification{}).CreateStepUsingLookup(tokens[0], nil)
	specText, err := getContentWithDataTable(content)
	if err != nil {
		return "", "", err
	}
	extractor := &extractor{conceptName: "* " + conceptName.GetName(), stepsInConcept: "", stepsToExtract: steps, conceptStep: conceptStep, table: &parser.Table{}, fileContent: specText, errors: make([]error, 0)}
	extractor.extractSteps()
	if len(extractor.errors) != 0 {
		return "", "", err
	}
	conceptStep.ReplaceArgsWithDynamic(conceptStep.Args)
	addArgsFromTable(conceptStep, &extractor.conceptName, extractor.dynamicArgs)
	if extractor.table.IsInitialized() {
		extractor.conceptName += "\n" + formatter.FormatTable(extractor.table)
	}
	return strings.Replace(formatter.FormatStep(conceptStep), "* ", "# ", 1) + (extractor.stepsInConcept), extractor.conceptName, nil
}
Ejemplo n.º 3
0
func (self *extractor) addTableAsParam(step *gauge_messages.Step, args []*parser.StepArg) {
	if step.GetParamTableName() != "" {
		self.conceptName = strings.Replace(self.conceptName, fmt.Sprintf("<%s>", step.GetParamTableName()), "", 1)
		self.table = &args[0].Table
		args[0] = &parser.StepArg{Value: step.GetParamTableName(), ArgType: parser.Dynamic}
	} else {
		self.dynamicArgs = append(self.dynamicArgs, (&args[0].Table).GetDynamicArgs()...)
	}
}