Skip to content

Commit

Permalink
Merge pull request #13 from TalentBox/allows-dash-in-tags
Browse files Browse the repository at this point in the history
Allows dash (`-`) in tags
  • Loading branch information
Josep M. Bach committed May 21, 2012
2 parents 7ba6d4b + e3a6b29 commit 5290138
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/gherkin/parser/gherkin.rex
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ rule
Scenario: { [:SCENARIO, text[0..-2]] } Scenario: { [:SCENARIO, text[0..-2]] }


# Tags # Tags
@\w+ { [:TAG, text[1..-1]] } @(\w|-)+ { [:TAG, text[1..-1]] }


# Step keywords # Step keywords
Given { [:GIVEN, text] } Given { [:GIVEN, text] }
Expand Down
2 changes: 1 addition & 1 deletion lib/gherkin/parser/lexer.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def _next_token
when (text = @ss.scan(/Scenario:/)) when (text = @ss.scan(/Scenario:/))
action { [:SCENARIO, text[0..-2]] } action { [:SCENARIO, text[0..-2]] }


when (text = @ss.scan(/@\w+/)) when (text = @ss.scan(/@(\w|-)+/))
action { [:TAG, text[1..-1]] } action { [:TAG, text[1..-1]] }


when (text = @ss.scan(/Given/)) when (text = @ss.scan(/Given/))
Expand Down
2 changes: 1 addition & 1 deletion lib/gherkin/parser/parser.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions test/gherkin/parser/parser_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def parse(input)
Given blah foo bar Given blah foo bar
Then something else Then something else
@javascript @wip @javascript @wip @with-vcr
Scenario: Foo bar baz blah Scenario: Foo bar baz blah
Given blah foo bar Given blah foo bar
Then something else Then something else
Expand All @@ -105,8 +105,9 @@ def parse(input)


last_scenario = scenarios.last last_scenario = scenarios.last


last_scenario.tags.first.name.must_equal "javascript" last_scenario.tags[0].name.must_equal "javascript"
last_scenario.tags.last.name.must_equal "wip" last_scenario.tags[1].name.must_equal "wip"
last_scenario.tags[2].name.must_equal "with-vcr"
end end
end end
end end
Expand Down

0 comments on commit 5290138

Please sign in to comment.