gherkin 1.0.30-universal-dotnet

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/.gitattributes +2 -0
  2. data/.gitignore +9 -0
  3. data/.mailmap +2 -0
  4. data/History.txt +187 -0
  5. data/LICENSE +20 -0
  6. data/README.rdoc +59 -0
  7. data/Rakefile +58 -0
  8. data/VERSION.yml +5 -0
  9. data/bin/gherkin +5 -0
  10. data/cucumber.yml +3 -0
  11. data/features/escaped_pipes.feature +8 -0
  12. data/features/feature_parser.feature +226 -0
  13. data/features/native_lexer.feature +19 -0
  14. data/features/parser_with_native_lexer.feature +205 -0
  15. data/features/pretty_printer.feature +14 -0
  16. data/features/step_definitions/eyeball_steps.rb +3 -0
  17. data/features/step_definitions/gherkin_steps.rb +30 -0
  18. data/features/step_definitions/pretty_formatter_steps.rb +55 -0
  19. data/features/steps_parser.feature +46 -0
  20. data/features/support/env.rb +33 -0
  21. data/ikvm/.gitignore +3 -0
  22. data/java/.gitignore +2 -0
  23. data/java/src/main/java/gherkin/lexer/.gitignore +1 -0
  24. data/java/src/main/resources/gherkin/.gitignore +1 -0
  25. data/lib/.gitignore +4 -0
  26. data/lib/gherkin.rb +2 -0
  27. data/lib/gherkin/c_lexer.rb +17 -0
  28. data/lib/gherkin/cli/main.rb +33 -0
  29. data/lib/gherkin/formatter/argument.rb +27 -0
  30. data/lib/gherkin/formatter/colors.rb +119 -0
  31. data/lib/gherkin/formatter/escaping.rb +15 -0
  32. data/lib/gherkin/formatter/monochrome_format.rb +9 -0
  33. data/lib/gherkin/formatter/pretty_formatter.rb +168 -0
  34. data/lib/gherkin/i18n.rb +176 -0
  35. data/lib/gherkin/i18n.yml +588 -0
  36. data/lib/gherkin/i18n_lexer.rb +38 -0
  37. data/lib/gherkin/native.rb +7 -0
  38. data/lib/gherkin/native/ikvm.rb +55 -0
  39. data/lib/gherkin/native/java.rb +47 -0
  40. data/lib/gherkin/native/null.rb +9 -0
  41. data/lib/gherkin/parser/event.rb +45 -0
  42. data/lib/gherkin/parser/filter_listener.rb +199 -0
  43. data/lib/gherkin/parser/meta.txt +5 -0
  44. data/lib/gherkin/parser/parser.rb +142 -0
  45. data/lib/gherkin/parser/root.txt +11 -0
  46. data/lib/gherkin/parser/steps.txt +4 -0
  47. data/lib/gherkin/parser/tag_expression.rb +50 -0
  48. data/lib/gherkin/rb_lexer.rb +8 -0
  49. data/lib/gherkin/rb_lexer/.gitignore +1 -0
  50. data/lib/gherkin/rb_lexer/README.rdoc +8 -0
  51. data/lib/gherkin/rubify.rb +18 -0
  52. data/lib/gherkin/tools.rb +8 -0
  53. data/lib/gherkin/tools/files.rb +35 -0
  54. data/lib/gherkin/tools/reformat.rb +19 -0
  55. data/lib/gherkin/tools/stats.rb +21 -0
  56. data/lib/gherkin/tools/stats_listener.rb +57 -0
  57. data/ragel/i18n/.gitignore +1 -0
  58. data/ragel/lexer.c.rl.erb +425 -0
  59. data/ragel/lexer.java.rl.erb +216 -0
  60. data/ragel/lexer.rb.rl.erb +173 -0
  61. data/ragel/lexer_common.rl.erb +50 -0
  62. data/spec/gherkin/c_lexer_spec.rb +21 -0
  63. data/spec/gherkin/csharp_lexer_spec.rb +20 -0
  64. data/spec/gherkin/fixtures/1.feature +8 -0
  65. data/spec/gherkin/fixtures/comments_in_table.feature +9 -0
  66. data/spec/gherkin/fixtures/complex.feature +45 -0
  67. data/spec/gherkin/fixtures/dos_line_endings.feature +45 -0
  68. data/spec/gherkin/fixtures/i18n_fr.feature +14 -0
  69. data/spec/gherkin/fixtures/i18n_no.feature +7 -0
  70. data/spec/gherkin/fixtures/i18n_zh-CN.feature +9 -0
  71. data/spec/gherkin/fixtures/simple_with_comments.feature +7 -0
  72. data/spec/gherkin/fixtures/simple_with_tags.feature +11 -0
  73. data/spec/gherkin/fixtures/with_bom.feature +3 -0
  74. data/spec/gherkin/formatter/argument_spec.rb +28 -0
  75. data/spec/gherkin/formatter/colors_spec.rb +19 -0
  76. data/spec/gherkin/formatter/pretty_formatter_spec.rb +162 -0
  77. data/spec/gherkin/formatter/spaces.feature +9 -0
  78. data/spec/gherkin/formatter/tabs.feature +9 -0
  79. data/spec/gherkin/i18n_lexer_spec.rb +26 -0
  80. data/spec/gherkin/i18n_spec.rb +144 -0
  81. data/spec/gherkin/java_lexer_spec.rb +21 -0
  82. data/spec/gherkin/parser/filter_listener_spec.rb +390 -0
  83. data/spec/gherkin/parser/parser_spec.rb +50 -0
  84. data/spec/gherkin/parser/tag_expression_spec.rb +116 -0
  85. data/spec/gherkin/rb_lexer_spec.rb +19 -0
  86. data/spec/gherkin/sexp_recorder.rb +32 -0
  87. data/spec/gherkin/shared/lexer_spec.rb +550 -0
  88. data/spec/gherkin/shared/py_string_spec.rb +150 -0
  89. data/spec/gherkin/shared/row_spec.rb +104 -0
  90. data/spec/gherkin/shared/tags_spec.rb +50 -0
  91. data/spec/spec_helper.rb +87 -0
  92. data/tasks/bench.rake +188 -0
  93. data/tasks/bench/feature_builder.rb +49 -0
  94. data/tasks/bench/generated/.gitignore +1 -0
  95. data/tasks/bench/null_listener.rb +4 -0
  96. data/tasks/compile.rake +89 -0
  97. data/tasks/cucumber.rake +26 -0
  98. data/tasks/gems.rake +45 -0
  99. data/tasks/ikvm.rake +47 -0
  100. data/tasks/ragel_task.rb +70 -0
  101. data/tasks/rdoc.rake +12 -0
  102. data/tasks/release.rake +26 -0
  103. data/tasks/rspec.rake +15 -0
  104. metadata +257 -0
@@ -0,0 +1,19 @@
1
+ Feature: Native (C/Java) Lexer
2
+
3
+ Background:
4
+ Given a "native" "root" parser
5
+
6
+ Scenario: Parsing an empty feature
7
+ Given the following text is parsed:
8
+ """
9
+ Feature: blah
10
+ """
11
+ Then there should be no parse errors
12
+
13
+ Scenario: Parsing a comment
14
+ Given the following text is parsed:
15
+ """
16
+ # A comment
17
+ Feature: Hello
18
+ """
19
+ Then there should be no parse errors
@@ -0,0 +1,205 @@
1
+ Feature: Gherkin Feature lexer/parser
2
+ In order to make it easy to control the Gherkin syntax
3
+ As a Gherkin developer bent on Gherkin world-domination
4
+ I want a feature lexer that uses a feature parser to
5
+ make all the syntax decisions for me
6
+
7
+ Background:
8
+ Given a "native" "root" parser
9
+
10
+ Scenario: Correctly formed feature
11
+ When the following text is parsed:
12
+ """
13
+ # Apologies to Bill Watterson
14
+ @cardboard_box @wip
15
+ Feature: Transmogrification
16
+ As a young boy with a hyperactive imagination
17
+ I want a cardboard box
18
+ In order to transform the ennui of suburban life into something
19
+ befitting my imagination
20
+
21
+ Background:
22
+ Given I have a transmogrifier
23
+ And I am a member of G.R.O.S.S
24
+
25
+ Scenario: Whoozit to whatzit transmogrification
26
+ Given I have a whoozit
27
+ When I put it in the transmogrifier
28
+ And I press the "transmogrify" button
29
+ Then I should have a whatzit
30
+
31
+ Scenario Outline: Imaginary Beings
32
+ Given I have a <boring being>
33
+ When I transmogrify it with the incantation:
34
+ \"\"\"
35
+ ALAKAZAM!
36
+ \"\"\"
37
+ Then I should have an <exciting being>
38
+
39
+ Examples:
40
+ | boring being | exciting being |
41
+ | Sparrow | Alicanto |
42
+ | Goldfish | Baldanders |
43
+ | Cow | Hsiao |
44
+
45
+ Scenario: Sense of humor detection
46
+ Given the following excerpt:
47
+ \"\"\"
48
+ WOMAN: Who are the Britons?
49
+ ARTHUR: Well, we all are. we're all Britons and I am your king.
50
+ WOMAN: I didn't know we had a king. I thought we were an autonomous
51
+ collective.
52
+ DENNIS: You're fooling yourself. We're living in a dictatorship.
53
+ A self-perpetuating autocracy in which the working classes--
54
+ WOMAN: Oh there you go, bringing class into it again.
55
+ DENNIS: That's what it's all about if only people would--
56
+ ARTHUR: Please, please good people. I am in haste. Who lives
57
+ in that castle?
58
+ \"\"\"
59
+ When I read it
60
+ Then I should be amused
61
+ """
62
+ Then there should be no parse errors
63
+
64
+ Scenario: Keyword before feature
65
+ When the following text is parsed:
66
+ """
67
+ Scenario: Bullying my way to the head of the line
68
+ Given I am a big bully of a scenario
69
+ Then I should be caught by the syntax police(y)
70
+
71
+ Feature: Too timid to stand up for myself
72
+ """
73
+ Then there should be parse errors on lines 1 through 3
74
+
75
+ Scenario: Tag ends background and scenario
76
+ When the following text is parsed:
77
+ """
78
+ Feature: test feature
79
+ Background:
80
+ Given a something
81
+ @tag
82
+ And something else
83
+
84
+ @foo
85
+ Scenario: my scenario
86
+ @tag
87
+ Given this is a step
88
+ @oh_hai
89
+ And this is a horrible idea
90
+ Then it shouldn't work
91
+ """
92
+ Then there should be parse errors on lines 5, 10 and 12
93
+
94
+ Scenario: Tables
95
+ When the following text is parsed:
96
+ """
97
+ Feature: Antiques Roadshow
98
+ Scenario Outline: Table
99
+ Given a <foo>
100
+ Then a <bar>
101
+
102
+ Examples:
103
+ | foo | bar |
104
+ | 42 | towel |
105
+ @hello
106
+ | 1 | prime |
107
+
108
+ Scenario: Table arguments
109
+ Given this step needs this table:
110
+ | foo | bar |
111
+ | one | two |
112
+ @tag
113
+ | aaa | bbb |
114
+ """
115
+ Then there should be parse errors on lines 10 and 17
116
+
117
+ Scenario: Multiline keyword descriptions
118
+ When the following text is parsed:
119
+ """
120
+ Feature: Documentation is fun
121
+ Scenario Outline: With lots of docs
122
+ We need lots of embedded documentation for some reason
123
+ \"\"\" # Not interpreted as a pystring, just plain text
124
+ Oh hai
125
+ \"\"\"
126
+
127
+ La la la
128
+
129
+ Examples:
130
+ | one | two |
131
+ | foo | bar |
132
+
133
+ \"\"\"
134
+ Oh Hello
135
+ \"\"\"
136
+
137
+ # Body of the scenario outline starts below
138
+ Given <something>
139
+ And something <else>
140
+
141
+ # The real examples table
142
+ Examples:
143
+ | something | else |
144
+ | orange | apple |
145
+ """
146
+ Then there should be no parse errors
147
+
148
+ Scenario: Scenario Outline with multiple Example groups
149
+ When the following text is parsed:
150
+ """
151
+ Feature: Outline Sample
152
+
153
+ Scenario: I have no steps
154
+
155
+ Scenario Outline: Test state
156
+ Given <state> without a table
157
+ Given <other_state> without a table
158
+
159
+ Examples: Rainbow colours
160
+ | state | other_state |
161
+ | missing | passing |
162
+ | passing | passing |
163
+ | failing | passing |
164
+
165
+ Examples: Only passing
166
+ | state | other_state |
167
+ | passing | passing |
168
+ """
169
+ Then there should be no parse errors
170
+
171
+ Scenario: Multiple Scenario Outlines with multiline outline steps
172
+ When the following text is parsed:
173
+ """
174
+ Feature: Test
175
+ Scenario Outline: with step tables
176
+ Given I have the following fruits in my pantry
177
+ | name | quantity |
178
+ | cucumbers | 10 |
179
+ | strawberrys | 5 |
180
+ | apricots | 7 |
181
+
182
+ When I eat <number> <fruits> from the pantry
183
+ Then I should have <left> <fruits> in the pantry
184
+
185
+ Examples:
186
+ | number | fruits | left |
187
+ | 2 | cucumbers | 8 |
188
+ | 4 | strawberrys | 1 |
189
+ | 2 | apricots | 5 |
190
+
191
+ Scenario Outline: placeholder in a multiline string
192
+ Given my shopping list
193
+ \"\"\"
194
+ Must buy some <fruits>
195
+ \"\"\"
196
+ Then my shopping list should equal
197
+ \"\"\"
198
+ Must buy some cucumbers
199
+ \"\"\"
200
+
201
+ Examples:
202
+ | fruits |
203
+ | cucumbers |
204
+ """
205
+ Then there should be no parse errors
@@ -0,0 +1,14 @@
1
+ Feature: Pretty printer
2
+ In order to have pretty gherkin
3
+ I want to verify that all prettified cucumber features parse OK
4
+
5
+ Scenario: Parse all the features in Cucumber
6
+ Given I have Cucumber's home dir defined in CUCUMBER_HOME
7
+ When I find all of the .feature files
8
+ And I parse the prettified representation of each of them
9
+ # Of course, we don't really want any errors. The last
10
+ # two files that were not identical are written to p1.feature
11
+ # and p2.feature. Do a diff -u p1.feature p2.feature
12
+ #
13
+ Then the following files should have errors:
14
+ | Path | Error |
@@ -0,0 +1,3 @@
1
+ Given /^they have arrived$/ do |table|
2
+ announce table.raw
3
+ end
@@ -0,0 +1,30 @@
1
+ Given /^a "([^\"]*)" "([^\"]*)" parser$/ do |ruby_or_native, parser_name|
2
+ parser = Gherkin::Parser::Parser.new(@listener, false, parser_name)
3
+ @lexer = Gherkin::I18nLexer.new(parser, ruby_or_native == "ruby")
4
+ end
5
+
6
+ Given "the following text is parsed:" do |text|
7
+ @lexer.scan(text)
8
+ end
9
+
10
+ Then "there should be no parse errors" do
11
+ @listener.errors.should == []
12
+ end
13
+
14
+ Then /^there should be a parse error on (line \d+)$/ do |line|
15
+ @listener.line(line).should include(:syntax_error, line)
16
+ end
17
+
18
+ Then /^there should be parse errors on (lines .*)$/ do |lines|
19
+ lines.each do |line|
20
+ Then "there should be a parse error on line #{line}"
21
+ end
22
+ end
23
+
24
+ Transform /^line \d+$/ do |step_arg|
25
+ tr_line_number(step_arg)
26
+ end
27
+
28
+ Transform /^lines .*$/ do |step_arg|
29
+ tr_line_numbers(step_arg)
30
+ end
@@ -0,0 +1,55 @@
1
+ require 'stringio'
2
+ require 'gherkin'
3
+ require 'gherkin/formatter/pretty_formatter'
4
+
5
+ module PrettyPlease
6
+ def pretty(source)
7
+ io = StringIO.new
8
+ listener = Gherkin::Formatter::PrettyFormatter.new(io)
9
+ parser = Gherkin::Parser::Parser.new(listener, true)
10
+ lexer = Gherkin::I18nLexer.new(parser)
11
+ lexer.scan(source)
12
+ io.rewind
13
+ io.read
14
+ end
15
+ end
16
+
17
+ World(PrettyPlease)
18
+
19
+ Given /^I have Cucumber's home dir defined in CUCUMBER_HOME$/ do
20
+ @cucumber_home = ENV['CUCUMBER_HOME']
21
+ raise "No CUCUMBER_HOME" if @cucumber_home.nil?
22
+ end
23
+
24
+ When /^I find all of the \.feature files$/ do
25
+ @features = Dir["#{@cucumber_home}/**/*.feature"].sort
26
+ end
27
+
28
+ When /^I parse the prettified representation of each of them$/ do
29
+ @errors = [['Path', 'Error']]
30
+ @features.each do |feature|
31
+ pretty1 = nil
32
+ pretty2 = nil
33
+ begin
34
+ pretty1 = pretty(IO.read(feature))
35
+ pretty2 = pretty(pretty1)
36
+ pretty2.should == pretty1
37
+ rescue Spec::Expectations::ExpectationNotMetError => e
38
+ File.open("p1.feature", "wb") {|io| io.write(pretty1)}
39
+ File.open("p2.feature", "wb") {|io| io.write(pretty2)}
40
+ announce "========== #{feature}:"
41
+ if(e.message =~ /(@@.*)/m)
42
+ announce $1
43
+ else
44
+ announce "??? NO DIFF ???"
45
+ end
46
+ @errors << [feature, "See announced diff"]
47
+ rescue => e
48
+ @errors << [feature, e.message]
49
+ end
50
+ end
51
+ end
52
+
53
+ Then /^the following files should have errors:$/ do |table|
54
+ table.diff!(@errors)
55
+ end
@@ -0,0 +1,46 @@
1
+ Feature: Gherkin Steps parser
2
+ In order to save time and make my features clearer
3
+ As a Cucumber developer
4
+ I want a steps parser to make writing compound steps easier
5
+
6
+ Background:
7
+ Given a "ruby" "steps" parser
8
+
9
+ Scenario: Parsing steps
10
+ Given the following text is parsed:
11
+ """
12
+ Given a one step
13
+ And a two step
14
+ \"\"\"
15
+ Here is a multiline string
16
+ That follows a step
17
+ With an argument #{arg}
18
+ \"\"\"
19
+ And a one two three step
20
+ When another step
21
+ Then there should be a table
22
+ | one | two | three |
23
+ | foo | bar | #{arg} |
24
+ """
25
+ Then there should be no parse errors
26
+
27
+ Scenario: Trying to parse a full feature with the step parser
28
+ Given the following text is parsed:
29
+ """
30
+ Feature: A Feature
31
+ Scenario: Yes, there is one
32
+ Given I have a step
33
+ When I execute this step
34
+ Then something should happen
35
+ """
36
+ Then there should be parse errors on lines 1 and 2
37
+
38
+ Scenario: Tags
39
+ Given the following text is parsed:
40
+ """
41
+ @a_tag
42
+ Given a step
43
+ When I trip
44
+ Then I should sign up for dancing lessons
45
+ """
46
+ Then there should be a parse error on line 1
@@ -0,0 +1,33 @@
1
+ # I'm sure there's a better way than this...
2
+ %w{/../../lib /../../spec/gherkin}.each do |path|
3
+ $LOAD_PATH << File.expand_path(File.dirname(__FILE__) + path)
4
+ end
5
+
6
+ require 'gherkin'
7
+ require "sexp_recorder"
8
+
9
+ module TransformHelpers
10
+ def tr_line_number(step_arg)
11
+ /(\d+)$/.match(step_arg)[0].to_i
12
+ end
13
+
14
+ def tr_line_numbers(step_arg)
15
+ if step_arg =~ /through/
16
+ Range.new(*step_arg.scan(/\d+/).collect { |i| i.to_i })
17
+ else
18
+ step_arg.scan(/\d+/).collect { |i| i.to_i }
19
+ end
20
+ end
21
+ end
22
+
23
+ class GherkinWorld
24
+ include TransformHelpers
25
+
26
+ def initialize
27
+ @listener = Gherkin::SexpRecorder.new
28
+ end
29
+ end
30
+
31
+ World do
32
+ GherkinWorld.new
33
+ end
@@ -0,0 +1,3 @@
1
+ bin
2
+ *.pidb
3
+ *.userprefs
@@ -0,0 +1,2 @@
1
+ .idea
2
+ target
@@ -0,0 +1 @@
1
+ *.properties
@@ -0,0 +1,4 @@
1
+ *.bundle
2
+ *.dll
3
+ *.so
4
+ *.jar
@@ -0,0 +1,2 @@
1
+ require 'gherkin/i18n_lexer'
2
+ require 'gherkin/parser/parser'
@@ -0,0 +1,17 @@
1
+ require 'rbconfig'
2
+
3
+ module Gherkin
4
+ module CLexer
5
+ def self.[](i18n_underscored_iso_code)
6
+ begin
7
+ prefix = Config::CONFIG['arch'] =~ /mswin|mingw/ ? "#{Config::CONFIG['MAJOR']}.#{Config::CONFIG['MINOR']}/" : ''
8
+ lib = "#{prefix}gherkin_lexer_#{i18n_underscored_iso_code}"
9
+ require lib
10
+ const_get(i18n_underscored_iso_code.capitalize)
11
+ rescue LoadError => e
12
+ e.message << %{\nCouldn't load #{lib}\nThe $LOAD_PATH was:\n#{$LOAD_PATH.join("\n")}}
13
+ raise e
14
+ end
15
+ end
16
+ end
17
+ end