Permalink
Browse files

Store feature description

In order for better formatters in Spinach to work
we need to store metadata like the feature description
so spinach formatters can retreive it and output it
  • Loading branch information...
1 parent 0f5c072 commit 722eacaff4a019b5349198d5c125c7b00b5edc1c @iain committed May 31, 2012
Showing with 23 additions and 8 deletions.
  1. +1 −0 lib/gherkin/ast.rb
  2. +3 −3 lib/gherkin/parser/gherkin.y
  3. +15 −5 lib/gherkin/parser/parser.rb
  4. +4 −0 test/gherkin/parser_test.rb
View
@@ -16,6 +16,7 @@ def pos(filename, line=nil)
class Feature < Node
attr_reader :name, :background, :scenarios, :tags
attr_writer :background, :scenarios, :tags
+ attr_accessor :description
include Enumerable
@@ -40,7 +40,7 @@ rule
FeatureName { result = val[0] }
| FeatureName Newline { result = val[0] }
| FeatureName Newline
- Description { result = val[0] }
+ Description { result = val[0]; result.description = val[2] }
;
FeatureName:
@@ -49,8 +49,8 @@ rule
;
Description:
- TEXT Newline
- | Description TEXT Newline
+ TEXT Newline { result = val[0] }
+ | Description TEXT Newline { result = val[0...-1].flatten }
;
Background:

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -32,6 +32,10 @@ module Gherkin
it 'generates a nice tree' do
@result.must_be_kind_of AST::Feature
@result.line.must_equal 1
+ @result.description.must_equal [
+ "In order to do something",
+ "As a developer",
+ "I want to be happy"]
background = @result.background
background.must_be_kind_of AST::Background

1 comment on commit 722eaca

ywen commented on 722eaca Oct 20, 2012

@iain what happens to this commit? does it make into the mainstream?

Please sign in to comment.