Skip to content

Commit

Permalink
Merge pull request #60 from antham/fix-consecutive-steps-parsing
Browse files Browse the repository at this point in the history
Fix consecutive scenario formatting
  • Loading branch information
antham authored Jul 28, 2021
2 parents d47ba9e + 169bfe5 commit 8e1c1c3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
8 changes: 8 additions & 0 deletions ghokin/fixtures/several-scenario-following.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Feature: A suite 1

Scenario: asdsad asdsad asdsad
Given the user disconnects the water

Scenario: as 123 dsad
Scenario: adsad
Scenario: asds asdsa ad
10 changes: 7 additions & 3 deletions ghokin/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ func transform(section *section, indentConf indent, aliases aliases) (bytes.Buff
continue
}

var err error
padding := paddings[sec.kind]
lines := formats[sec.kind](sec.values)

Expand Down Expand Up @@ -144,7 +143,6 @@ func computeCommand(cmd *exec.Cmd, lines []string, sec *section) (bool, []string
}

l, err := runCommand(cmd, lines)

if err != nil {
return true, []string{}, err
}
Expand Down Expand Up @@ -233,7 +231,13 @@ func extractTokensKeywordAndText(tokens []*gherkin.Token) []string {
}

func extractKeywordAndTextSeparatedWithAColon(tokens []*gherkin.Token) []string {
return []string{fmt.Sprintf("%s: %s", tokens[0].Keyword, tokens[0].Text)}
content := []string{}

for _, token := range tokens {
content = append(content, fmt.Sprintf("%s: %s", token.Keyword, token.Text))
}

return content
}

func extractKeyword(tokens []*gherkin.Token) []string {
Expand Down
4 changes: 4 additions & 0 deletions ghokin/transformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,10 @@ func TestTransform(t *testing.T) {
"fixtures/escape-pipe.feature",
"fixtures/escape-pipe.feature",
},
{
"fixtures/several-scenario-following.feature",
"fixtures/several-scenario-following.feature",
},
}

for _, scenario := range scenarios {
Expand Down

0 comments on commit 8e1c1c3

Please sign in to comment.