コード例 #1
0
ファイル: resolver.go プロジェクト: mattdotmatt/gauge
// Creating a copy of the lookup and populating table values
func PopulateConceptDynamicParams(concept *gauge.Step, dataTableLookup *gauge.ArgLookup) {
	//If it is a top level concept
	if concept.Parent == nil {
		lookup := concept.Lookup.GetCopy()
		for key, _ := range lookup.ParamIndexMap {
			conceptLookupArg := lookup.GetArg(key)
			if conceptLookupArg.ArgType == gauge.Dynamic {
				resolvedArg := dataTableLookup.GetArg(conceptLookupArg.Value)
				lookup.AddArgValue(key, resolvedArg)
			}
		}
		concept.Lookup = *lookup
	}

	//Updating values inside the concept step as well
	newArgs := make([]*gauge.StepArg, 0)
	for _, arg := range concept.Args {
		if arg.ArgType == gauge.Dynamic {
			if concept.Parent != nil {
				newArgs = append(newArgs, concept.Parent.GetArg(arg.Value))
			} else {
				newArgs = append(newArgs, dataTableLookup.GetArg(arg.Value))
			}
		} else {
			newArgs = append(newArgs, arg)
		}
	}
	concept.Args = newArgs
	concept.PopulateFragments()
}
コード例 #2
0
ファイル: conceptExtractor.go プロジェクト: mattdotmatt/gauge
func addArgsFromTable(concept *gauge.Step, conceptName *string, args []string) {
	for _, arg := range args {
		concept.Value += " {}"
		concept.Args = append(concept.Args, &gauge.StepArg{Value: arg, ArgType: gauge.Dynamic, Name: arg})
		*conceptName += fmt.Sprintf(" <%s>", arg)
	}
}
コード例 #3
0
ファイル: conceptExtractor.go プロジェクト: mattdotmatt/gauge
func (self *extractor) handleTable(stepInConcept *gauge.Step, step *gauge_messages.Step) {
	stepInConcept.Value += " {}"
	specText := self.fileContent + step.GetTable()
	spec, result := new(parser.SpecParser).Parse(specText, &gauge.ConceptDictionary{})
	if !result.Ok {
		self.errors = append(self.errors, result.ParseError)
		return
	}
	stepArgs := []*gauge.StepArg{spec.Scenarios[0].Steps[0].Args[0]}
	self.addTableAsParam(step, stepArgs)
	stepInConcept.Args = append(stepInConcept.Args, stepArgs[0])
}
コード例 #4
0
ファイル: specparser.go プロジェクト: 0-T-0/gauge
func createConceptStep(spec *gauge.Specification, concept *gauge.Step, originalStep *gauge.Step) {
	stepCopy := concept.GetCopy()
	originalArgs := originalStep.Args
	originalStep.CopyFrom(stepCopy)
	originalStep.Args = originalArgs

	// set parent of all concept steps to be the current concept (referred as originalStep here)
	// this is used to fetch from parent's lookup when nested
	for _, conceptStep := range originalStep.ConceptSteps {
		conceptStep.Parent = originalStep
	}

	spec.PopulateConceptLookup(&originalStep.Lookup, concept.Args, originalStep.Args)
}