Skip to content

Commit

Permalink
Allow tags to be applied to Feature
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanTron committed May 21, 2012
1 parent 5290138 commit 6412dfb
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 Original file line Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ def pos(filename, line=nil)
end end


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


include Enumerable include Enumerable


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


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


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


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

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

0 comments on commit 6412dfb

Please sign in to comment.