Skip to content

Commit

Permalink
Extract method
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Meyer committed Apr 10, 2015
1 parent 4c4b6c4 commit 7075869
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ func (parser *wire_protocol_parser) step_matches(parameters json.RawMessage) str
func (parser *wire_protocol_parser) snippet_text(parameters json.RawMessage) string {
var snippet map[string]string
json.Unmarshal(parameters, &snippet)
name := strings.Replace(snippet["step_name"], "\"", "\\\"", -1)
keyword := snippet["step_keyword"]
snippet_text, _ := json.Marshal(`cucumber.` + keyword + `("` + name + `").Pending()`)
return `["success",` + string(snippet_text) + `]`
return success_response_snippet(snippet["step_name"], snippet["step_keyword"])
}

func (parser *wire_protocol_parser) invoke(parameters json.RawMessage) string {
Expand Down Expand Up @@ -111,3 +108,8 @@ func success_response_steps(id string, arguments []capturing_group) string {
return `["success",[{"id":"` + id + `","args":[` + arguments_string + `]}]]`
}

func success_response_snippet(name string, keyword string) string {
escaped_name := strings.Replace(name, "\"", "\\\"", -1)
snippet_text, _ := json.Marshal(`cucumber.` + keyword + `("` + escaped_name + `").Pending()`)
return `["success",` + string(snippet_text) + `]`
}

0 comments on commit 7075869

Please sign in to comment.