Skip to content

Commit

Permalink
Merge pull request codegram#15 from TalentBox/allow-tags-for-features
Browse files Browse the repository at this point in the history
Allow tags to be applied to Feature
  • Loading branch information
josepjaume committed May 21, 2012
2 parents 5290138 + 6412dfb commit f1dbf46
Show file tree
Hide file tree
Showing 5 changed files with 204 additions and 135 deletions.
7 changes: 4 additions & 3 deletions lib/gherkin/ast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ def pos(filename, line=nil)
end

class Feature < Node
attr_reader :name, :background, :scenarios
attr_writer :background, :scenarios
attr_reader :name, :background, :scenarios, :tags
attr_writer :background, :scenarios, :tags

include Enumerable

def initialize(name, scenarios=[], background=nil)
def initialize(name, scenarios=[], tags=[], background=nil)
@name = name
@background = background
@tags = tags
@scenarios = scenarios
end

Expand Down
9 changes: 8 additions & 1 deletion lib/gherkin/parser/gherkin.y
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class Gherkin::Parser

# Declare tokens produced by the lexer
token NEWLINE
token NEWLINE START
token FEATURE BACKGROUND SCENARIO
token TAG
token GIVEN WHEN THEN AND BUT
Expand All @@ -16,13 +16,20 @@ rule
|
Feature
Scenarios { result = val[0]; result.scenarios = val[1] }
| FeatureTags Feature { result = val[1]; result.tags = val[0] }
| FeatureTags Feature
Scenarios { result = val[1]; result.scenarios = val[2]; result.tags = val[0] }
;

Newline:
NEWLINE
| Newline NEWLINE
;

FeatureTags:
Tags { result = val[0] }
| Newline Tags { result = val[1] }

Feature:
FeatureHeader { result = val[0] }
| FeatureHeader
Expand Down
Loading

0 comments on commit f1dbf46

Please sign in to comment.