bryanl-gherkin 2.11.1.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. data/.gitattributes +2 -0
  2. data/.mailmap +2 -0
  3. data/.rbenv-gemsets +1 -0
  4. data/.rspec +1 -0
  5. data/.rvmrc +1 -0
  6. data/.travis.yml +16 -0
  7. data/.yardopts +5 -0
  8. data/Gemfile +5 -0
  9. data/History.md +788 -0
  10. data/LICENSE +20 -0
  11. data/README.md +272 -0
  12. data/Rakefile +26 -0
  13. data/build_native_gems.sh +7 -0
  14. data/cucumber.yml +4 -0
  15. data/examples/parse_and_output_json.rb +19 -0
  16. data/features/.cucumber/stepdefs.json +244 -0
  17. data/features/escaped_pipes.feature +8 -0
  18. data/features/feature_parser.feature +237 -0
  19. data/features/json_formatter.feature +498 -0
  20. data/features/json_parser.feature +331 -0
  21. data/features/native_lexer.feature +19 -0
  22. data/features/parser_with_native_lexer.feature +205 -0
  23. data/features/pretty_formatter.feature +16 -0
  24. data/features/step_definitions/eyeball_steps.rb +3 -0
  25. data/features/step_definitions/gherkin_steps.rb +29 -0
  26. data/features/step_definitions/json_formatter_steps.rb +30 -0
  27. data/features/step_definitions/json_parser_steps.rb +20 -0
  28. data/features/step_definitions/pretty_formatter_steps.rb +85 -0
  29. data/features/steps_parser.feature +46 -0
  30. data/features/support/env.rb +42 -0
  31. data/gherkin.gemspec +77 -0
  32. data/install_mingw_os_x.sh +7 -0
  33. data/js/.npmignore +1 -0
  34. data/js/lib/gherkin/lexer/.npmignore +0 -0
  35. data/lib/gherkin/c_lexer.rb +17 -0
  36. data/lib/gherkin/formatter/ansi_escapes.rb +97 -0
  37. data/lib/gherkin/formatter/argument.rb +16 -0
  38. data/lib/gherkin/formatter/escaping.rb +15 -0
  39. data/lib/gherkin/formatter/filter_formatter.rb +146 -0
  40. data/lib/gherkin/formatter/hashable.rb +19 -0
  41. data/lib/gherkin/formatter/json_formatter.rb +122 -0
  42. data/lib/gherkin/formatter/line_filter.rb +26 -0
  43. data/lib/gherkin/formatter/model.rb +281 -0
  44. data/lib/gherkin/formatter/pretty_formatter.rb +244 -0
  45. data/lib/gherkin/formatter/regexp_filter.rb +21 -0
  46. data/lib/gherkin/formatter/step_printer.rb +21 -0
  47. data/lib/gherkin/formatter/tag_count_formatter.rb +47 -0
  48. data/lib/gherkin/formatter/tag_filter.rb +19 -0
  49. data/lib/gherkin/i18n.rb +180 -0
  50. data/lib/gherkin/i18n.yml +613 -0
  51. data/lib/gherkin/js_lexer.rb +20 -0
  52. data/lib/gherkin/json_parser.rb +177 -0
  53. data/lib/gherkin/lexer/i18n_lexer.rb +46 -0
  54. data/lib/gherkin/listener/event.rb +45 -0
  55. data/lib/gherkin/listener/formatter_listener.rb +143 -0
  56. data/lib/gherkin/native/java.rb +72 -0
  57. data/lib/gherkin/native/null.rb +5 -0
  58. data/lib/gherkin/native/therubyracer.rb +39 -0
  59. data/lib/gherkin/native.rb +7 -0
  60. data/lib/gherkin/parser/meta.txt +5 -0
  61. data/lib/gherkin/parser/parser.rb +164 -0
  62. data/lib/gherkin/parser/root.txt +11 -0
  63. data/lib/gherkin/parser/steps.txt +4 -0
  64. data/lib/gherkin/rb_lexer/README.rdoc +8 -0
  65. data/lib/gherkin/rb_lexer.rb +8 -0
  66. data/lib/gherkin/rubify.rb +24 -0
  67. data/lib/gherkin/tag_expression.rb +62 -0
  68. data/lib/gherkin.jar +0 -0
  69. data/lib/gherkin.rb +2 -0
  70. data/ragel/lexer.c.rl.erb +454 -0
  71. data/ragel/lexer.java.rl.erb +219 -0
  72. data/ragel/lexer.js.rl.erb +227 -0
  73. data/ragel/lexer.rb.rl.erb +174 -0
  74. data/ragel/lexer_common.rl.erb +50 -0
  75. data/spec/gherkin/c_lexer_spec.rb +22 -0
  76. data/spec/gherkin/fixtures/1.feature +8 -0
  77. data/spec/gherkin/fixtures/comments_in_table.feature +9 -0
  78. data/spec/gherkin/fixtures/complex.feature +45 -0
  79. data/spec/gherkin/fixtures/complex.json +139 -0
  80. data/spec/gherkin/fixtures/complex_for_filtering.feature +60 -0
  81. data/spec/gherkin/fixtures/complex_with_tags.feature +61 -0
  82. data/spec/gherkin/fixtures/dos_line_endings.feature +45 -0
  83. data/spec/gherkin/fixtures/examples_with_only_header.feature +14 -0
  84. data/spec/gherkin/fixtures/hantu_pisang.feature +35 -0
  85. data/spec/gherkin/fixtures/i18n_fr.feature +14 -0
  86. data/spec/gherkin/fixtures/i18n_fr2.feature +8 -0
  87. data/spec/gherkin/fixtures/i18n_no.feature +7 -0
  88. data/spec/gherkin/fixtures/i18n_pt1.feature +44 -0
  89. data/spec/gherkin/fixtures/i18n_pt2.feature +4 -0
  90. data/spec/gherkin/fixtures/i18n_pt3.feature +4 -0
  91. data/spec/gherkin/fixtures/i18n_pt4.feature +4 -0
  92. data/spec/gherkin/fixtures/i18n_zh-CN.feature +9 -0
  93. data/spec/gherkin/fixtures/issue_145.feature +22 -0
  94. data/spec/gherkin/fixtures/scenario_outline_with_tags.feature +13 -0
  95. data/spec/gherkin/fixtures/scenario_without_steps.feature +5 -0
  96. data/spec/gherkin/fixtures/simple_with_comments.feature +7 -0
  97. data/spec/gherkin/fixtures/simple_with_tags.feature +11 -0
  98. data/spec/gherkin/fixtures/with_bom.feature +3 -0
  99. data/spec/gherkin/formatter/ansi_escapes_spec.rb +32 -0
  100. data/spec/gherkin/formatter/filter_formatter_spec.rb +204 -0
  101. data/spec/gherkin/formatter/json_formatter_spec.rb +92 -0
  102. data/spec/gherkin/formatter/model_spec.rb +28 -0
  103. data/spec/gherkin/formatter/pretty_formatter_spec.rb +177 -0
  104. data/spec/gherkin/formatter/spaces.feature +9 -0
  105. data/spec/gherkin/formatter/step_printer_spec.rb +55 -0
  106. data/spec/gherkin/formatter/tabs.feature +9 -0
  107. data/spec/gherkin/formatter/tag_count_formatter_spec.rb +30 -0
  108. data/spec/gherkin/i18n_spec.rb +241 -0
  109. data/spec/gherkin/java_lexer_spec.rb +20 -0
  110. data/spec/gherkin/js_lexer_spec.rb +23 -0
  111. data/spec/gherkin/json_parser_spec.rb +176 -0
  112. data/spec/gherkin/lexer/i18n_lexer_spec.rb +43 -0
  113. data/spec/gherkin/output_stream_string_io.rb +20 -0
  114. data/spec/gherkin/parser/parser_spec.rb +16 -0
  115. data/spec/gherkin/rb_lexer_spec.rb +20 -0
  116. data/spec/gherkin/sexp_recorder.rb +59 -0
  117. data/spec/gherkin/shared/bom_group.rb +20 -0
  118. data/spec/gherkin/shared/doc_string_group.rb +163 -0
  119. data/spec/gherkin/shared/lexer_group.rb +591 -0
  120. data/spec/gherkin/shared/row_group.rb +125 -0
  121. data/spec/gherkin/shared/tags_group.rb +54 -0
  122. data/spec/gherkin/tag_expression_spec.rb +142 -0
  123. data/spec/spec_helper.rb +75 -0
  124. data/tasks/bench/feature_builder.rb +49 -0
  125. data/tasks/bench/null_listener.rb +4 -0
  126. data/tasks/bench.rake +184 -0
  127. data/tasks/compile.rake +120 -0
  128. data/tasks/cucumber.rake +22 -0
  129. data/tasks/gems.rake +31 -0
  130. data/tasks/ikvm.rake +124 -0
  131. data/tasks/ragel_task.rb +100 -0
  132. data/tasks/release.rake +49 -0
  133. data/tasks/rspec.rake +8 -0
  134. data/tasks/yard/default/layout/html/bubble_32x32.png +0 -0
  135. data/tasks/yard/default/layout/html/bubble_48x48.png +0 -0
  136. data/tasks/yard/default/layout/html/footer.erb +5 -0
  137. data/tasks/yard/default/layout/html/index.erb +1 -0
  138. data/tasks/yard/default/layout/html/layout.erb +25 -0
  139. data/tasks/yard/default/layout/html/logo.erb +1 -0
  140. data/tasks/yard/default/layout/html/setup.rb +4 -0
  141. data/tasks/yard.rake +7 -0
  142. metadata +412 -0
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009-2012 Mike Sassak, Gregory Hnatiuk, Aslak Hellesøy
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,272 @@
1
+ [![Build Status](https://secure.travis-ci.org/cucumber/gherkin.png)](http://travis-ci.org/cucumber/gherkin)
2
+
3
+ A fast lexer and parser for the Gherkin language based on Ragel. Gherkin is two things:
4
+
5
+ * The language that has evolved out of the Cucumber project.
6
+ * This library.
7
+
8
+ Supported platforms:
9
+
10
+ * [Ruby](https://rubygems.org/gems/gherkin) 1.8.7-1.9.3 (MRI, JRuby, REE, Rubinius)
11
+ * [Pure Java](http://search.maven.org/#search%7Cga%7C1%7Cgherkin) (jar file)
12
+ * [JavaScript](http://search.npmjs.org/#/gherkin) (Tested with V8/node.js/Chrome, but might work on other JavaScript engines)
13
+ * [.NET](http://nuget.org/List/Packages/gherkin) (dll file)
14
+
15
+ ## Installation
16
+
17
+ ### Ruby/JRuby
18
+
19
+ gem install gherkin
20
+
21
+ #### Troubleshooting
22
+
23
+ On JRuby you may get an error saying:
24
+
25
+ ERROR: While executing gem ... (ArgumentError)
26
+ undefined class/module YAML::Syck::DefaultKey
27
+
28
+ You can get around this problem by upgrading rubygems:
29
+
30
+ jruby -S gem install rubygems-update
31
+ gem update --system
32
+
33
+ Another problem you might encounter is:
34
+
35
+ ERROR: While executing gem ... (ArgumentError)
36
+ invalid byte sequence in US-ASCII
37
+
38
+ If this happens, try defining your shell's encoding:
39
+
40
+ # Linux
41
+ export LANG=en_US.UTF-8
42
+
43
+ # OS X
44
+ export LC_CTYPE=en_US.UTF-8
45
+
46
+ ### Node.js
47
+
48
+ npm install gherkin
49
+
50
+ ### Java
51
+
52
+ The jar file is in the central Maven repo.
53
+
54
+ <dependency>
55
+ <groupId>info.cukes</groupId>
56
+ <artifactId>gherkin</artifactId>
57
+ <version>2.11.1</version>
58
+ </dependency>
59
+
60
+ You can get it manually from [Maven Central](http://search.maven.org/#browse%7C-2073395818)
61
+
62
+ ### .NET
63
+
64
+ Get the dll from [NuGet](http://nuget.org/List/Packages/gherkin)
65
+
66
+ ## API Docs
67
+
68
+ * [Ruby](http://cukes.info/gherkin/api/ruby/latest/)
69
+ * [Java](http://cukes.info/gherkin/api/java/latest/apidocs/index.html)
70
+
71
+ ## Hacking: Installing the toolchain
72
+
73
+ Due to the cross-platform nature of this library, you have to install a lot of tools to build gherkin yourself.
74
+ In order to make it easier for occasional contributors to get the development environment up and running, you don't
75
+ have to install everything up front. The build scripts should tell you if you are missing something. For example,
76
+ you shouldn't have to install MinGW to build windows binaries if you are a Linux user and just want to fix a bug in
77
+ the C code.
78
+
79
+ ### Common dependencies
80
+
81
+ These are the minimal tools you need to install:
82
+
83
+ * Ragel (brew install ragel or apt-get install ragel)
84
+ * Ruby (any version should do).
85
+ * A clone of the cucumber git repo to a "cucumber" sibling folder of your gherkin folder. (Only needed to run cucumber tests)
86
+ * RVM (you may not need this if you are only building for a single platform)
87
+
88
+ With this minimal tool chain installed, install Ruby gems needed by the build:
89
+
90
+ gem install bundler
91
+ bundle install
92
+
93
+ Running RSpec and Cucumber tests
94
+
95
+ rake clean spec cucumber
96
+
97
+ If the RL_LANGS environment variable is set, only the parsers for the languages specified there will be built.
98
+ E.g. in Bash, export RL_LANGS="en,fr,no". This can be quite helpful when modifying the Ragel grammar.
99
+
100
+ See subsections for building for a specific platform.
101
+
102
+ ### MRI, REE or Rubinius
103
+
104
+ You'll need GCC installed.
105
+
106
+ Build the gem with:
107
+
108
+ rake build
109
+
110
+ ### Pure Java and JRuby
111
+
112
+ You must install JRuby to build the pure Java jar or the JRuby gem:
113
+
114
+ rvm install jruby
115
+ rvm use jruby
116
+ rvm gemset create cucumber
117
+ rvm gemset use cucumber
118
+ gem install bundler
119
+ bundle install
120
+
121
+ Now you can build the jar with:
122
+
123
+ rake clean jar
124
+
125
+ ### JavaScript
126
+
127
+ In order to build and test Gherkin for JavaScript you must install:
128
+
129
+ * Node.js (0.6.17 or higher with npm)
130
+ * Ragel with JavaScript support: http://github.com/dominicmarks/ragel-js
131
+ * Make sure you have `autoconf` and `automake` (`brew install automake`)
132
+ * Make sure you have the official ragel (`brew install ragel`)
133
+ * Make sure you have kelbt (`brew install kelbt`). If that fails, install manually from http://www.complang.org/kelbt/
134
+ * `cd ragel-js/ragel-svn && ./autogen.sh && ./configure --disable-manual`
135
+ * `make && make install`
136
+ * Define the GHERKIN_JS environment variable in your shell (any value will do)
137
+
138
+ Now you can build the JavaScript with:
139
+
140
+ rake js
141
+
142
+ And you can try it out with node.js:
143
+
144
+ node js/example/print.js spec/gherkin/fixtures/1.feature
145
+
146
+ Or the json formatter:
147
+
148
+ node js/example/json_fomratter_example.js
149
+
150
+ If you're hacking and just want to rebuild the English parser:
151
+
152
+ rake js/lib/gherkin/lexer/en.js
153
+
154
+ In order to test the native JavaScript implementation of JSONFormatter, you also need to define the `GHERKIN_JS_NATIVE` environment
155
+ variable. It's recommended you don't do this permanently, as it will disable testing the Ruby implementation. Try this instead:
156
+
157
+ GHERKIN_JS_NATIVE=true GHERKIN_JS=true bundle exec rake
158
+
159
+ TODO: Make all specs pass with js lexer - replace 'c(listener)' with 'js(listener)' in i18n.rb
160
+
161
+ ### .NET dll
162
+
163
+ You must install Mono SDK 2.10.8. The OS X package installer is not recommended as it modifies your system PATH and makes Homebrew unhappy. Install with homebrew instead:
164
+
165
+ brew install ikvm/mono.rb
166
+
167
+ You must also download NuGet.exe from [CodePlex](http://nuget.codeplex.com/releases) and place it in `/usr/local/nuget/NuGet.exe`. When it's installed, update it and register your NuGet API Key:
168
+
169
+ # In case we need to update
170
+ mono /usr/local/nuget/NuGet.exe Update -self
171
+
172
+ # The key is at https://nuget.org/account
173
+ mono --runtime=v4.0.30319 /usr/local/nuget/NuGet.exe SetApiKey xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx
174
+
175
+ Now you can build the .NET dll with:
176
+
177
+ mkdir release
178
+ rake ikvm
179
+ rake release/nuspec/lib/gherkin.dll
180
+
181
+ This should build `release/nuspec/lib/gherkin.dll`
182
+
183
+ ### MinGW Rubies (for Windows gems)
184
+
185
+ In order to build Windows binaries (so we can release Windows gems from OS X/Linux) we first need to install MinGW:
186
+
187
+ ./install_mingw_os_x.sh
188
+
189
+ Now, make sure you have openssl installed - it's needed to build the rubies.
190
+
191
+ brew install openssl
192
+
193
+ Next, we're going to install Ruby 1.8.7 and Ruby 1.9.3 for MinGW. We need both versions so we can build Windows binaries for both.
194
+ OS X Lion (or later) doesn't ship with an LLVM free gcc, which you will need in order to install ruby 1.8.7. We can install it with:
195
+
196
+ brew install https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb
197
+
198
+ For more info see:
199
+
200
+ * http://stackoverflow.com/questions/6170813/why-cant-i-install-rails-on-lion-using-rvm
201
+ * https://github.com/mxcl/homebrew/wiki/Custom-GCC-and-cross-compilers
202
+
203
+ Now we're ready to install the Windows rubies:
204
+
205
+ unset GHERKIN_JS
206
+
207
+ # 1.9.3
208
+ rvm install 1.9.3-p194
209
+ rvm use 1.9.3-p194
210
+ rvm gemset create cucumber
211
+ rvm gemset use cucumber
212
+ gem install bundler
213
+ bundle install
214
+ PATH=/usr/local/mingw/bin:$PATH CC=/usr/local/mingw/bin/i686-w64-mingw32-gcc rake-compiler cross-ruby VERSION=1.9.3-p194
215
+
216
+ # 1.8.7
217
+ CC=gcc-4.2 rvm install 1.8.7-p352
218
+ rvm use 1.8.7-p352
219
+ rvm gemset create cucumber
220
+ rvm gemset use cucumber
221
+ gem install bundler
222
+ bundle install
223
+ PATH=/usr/local/mingw/bin:$PATH CC=/usr/local/mingw/bin/i686-w64-mingw32-gcc rake-compiler cross-ruby VERSION=1.8.7-p352
224
+
225
+ Now you can build Windows gems:
226
+
227
+ rake compile
228
+ mkdir release
229
+ rake gems:win
230
+
231
+ ## Release process
232
+
233
+ Make sure you have access to all the servers where packages are being uploaded:
234
+
235
+ * npm registry: `npm login`
236
+ * rubygems.org: `gem push`
237
+ * cukes.info: `ssh cukes.info`
238
+ * sonatype: Check `~/.m2/settings.xml` and that you have gnupg (OS X users: Install [GPGTools](http://www.gpgtools.org/installer/index.html))
239
+ * Make sure you have a key [with no sub-key](https://docs.sonatype.org/display/Repository/How+To+Generate+PGP+Signatures+With+Maven)
240
+ * nuget: See .NET section above
241
+
242
+ Run tests once with GHERKIN_JS_NATIVE=true:
243
+
244
+ GHERKIN_JS_NATIVE=true GHERKIN_JS=true bundle exec rake
245
+
246
+ Now we can release:
247
+
248
+ * Make sure GHERKIN_JS is defined (see JavaScript section above)
249
+ * Bump version in:
250
+ * This file (Installation/Java section)
251
+ * gherkin.gemspec
252
+ * java/pom.xml
253
+ * js/package.json
254
+ * Run `bundle update`, so Gemfile.lock gets updated with the changes.
255
+ * Commit changes, otherwise you will get an error at the end when a tag is made.
256
+ * Run `bundle exec rake gems:prepare && ./build_native_gems.sh && bundle exec rake release:ALL`
257
+
258
+ ## Note on Patches/Pull Requests
259
+
260
+ * Fork the project.
261
+ * Run rake ragel:rb to generate all the I18n lexers
262
+ * Make your feature addition or bug fix.
263
+ * Add tests for it. This is important so I don't break it in a
264
+ future version unintentionally.
265
+ * Commit, do not mess with Rakefile, VERSION, or History.txt.
266
+ (if you want to have your own version, that is fine but
267
+ bump version in a commit by itself I can ignore when I pull)
268
+ * Send me a pull request. Bonus points for topic branches.
269
+
270
+ ## Copyright
271
+
272
+ Copyright (c) 2009-2012 Mike Sassak, Gregory Hnatiuk, Aslak Hellesøy. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+ GHERKIN_VERSION = Gem::Specification.load(File.dirname(__FILE__) + '/gherkin.gemspec').version.version
3
+ require 'rubygems'
4
+ unless ENV['RUBY_CC_VERSION']
5
+ require 'bundler'
6
+ Bundler.setup
7
+ Bundler::GemHelper.install_tasks
8
+ end
9
+ ENV['RUBYOPT'] = nil # Necessary to prevent Bundler from *&^%$#ing up rake-compiler.
10
+
11
+ require 'rake/clean'
12
+
13
+ begin
14
+ # Support Rake >= 0.9.0
15
+ require 'rake/dsl_definition'
16
+ include Rake::DSL
17
+ rescue LoadError
18
+ end
19
+
20
+ $:.unshift(File.dirname(__FILE__) + '/lib')
21
+
22
+ Dir['tasks/**/*.rake'].each { |rake| load File.expand_path(rake) }
23
+
24
+ task :default => [:spec, :cucumber]
25
+ task :spec => defined?(JRUBY_VERSION) ? :jar : :compile
26
+ task :cucumber => defined?(JRUBY_VERSION) ? :jar : :compile
@@ -0,0 +1,7 @@
1
+ #!/bin/sh
2
+ rm -Rf release
3
+ mkdir release
4
+ GEM_PLATFORM=java gem build gherkin.gemspec
5
+ GEM_PLATFORM=x86-mswin32 gem build gherkin.gemspec
6
+ GEM_PLATFORM=x86-mingw32 gem build gherkin.gemspec
7
+ mv *.gem release
data/cucumber.yml ADDED
@@ -0,0 +1,4 @@
1
+ default: --format pretty --tags ~@pending,~@wip --strict --color --dotcucumber features/.cucumber features
2
+ wip: --format pretty --tags @wip --wip features
3
+ pending: --format pretty --tags @pending,~@native_lexer
4
+ travis: --format pretty --tags ~@cucumber-source-available
@@ -0,0 +1,19 @@
1
+ require 'gherkin/parser/parser'
2
+ require 'gherkin/formatter/json_formatter'
3
+ require 'stringio'
4
+ require 'json'
5
+
6
+ # This example reads a couple of features and outputs them as JSON.
7
+
8
+ io = StringIO.new
9
+ formatter = Gherkin::Formatter::JSONFormatter.new(io)
10
+ parser = Gherkin::Parser::Parser.new(formatter)
11
+
12
+ sources = ["features/native_lexer.feature", "features/escaped_pipes.feature"]
13
+ sources.each do |s|
14
+ path = File.expand_path(File.dirname(__FILE__) + '/../' + s)
15
+ parser.parse(IO.read(path), path, 0)
16
+ end
17
+
18
+ formatter.done
19
+ puts JSON.pretty_generate(JSON.parse(io.string))
@@ -0,0 +1,244 @@
1
+ [
2
+ {
3
+ "file_colon_line": "features/step_definitions/eyeball_steps.rb:1",
4
+ "flags": "",
5
+ "source": "^they have arrived$",
6
+ "steps": [
7
+ {
8
+ "args": [
9
+
10
+ ],
11
+ "name": "they have arrived"
12
+ }
13
+ ]
14
+ },
15
+ {
16
+ "file_colon_line": "features/step_definitions/gherkin_steps.rb:1",
17
+ "flags": "",
18
+ "source": "^a \"(ruby|native)\" \"([^\\\"]*)\" parser$",
19
+ "steps": [
20
+
21
+ ]
22
+ },
23
+ {
24
+ "file_colon_line": "features/step_definitions/gherkin_steps.rb:5",
25
+ "flags": "",
26
+ "source": "^the\\ following\\ text\\ is\\ parsed:$",
27
+ "steps": [
28
+ {
29
+ "args": [
30
+
31
+ ],
32
+ "name": "the following text is parsed:"
33
+ }
34
+ ]
35
+ },
36
+ {
37
+ "file_colon_line": "features/step_definitions/gherkin_steps.rb:9",
38
+ "flags": "",
39
+ "source": "^there\\ should\\ be\\ no\\ parse\\ errors$",
40
+ "steps": [
41
+ {
42
+ "args": [
43
+
44
+ ],
45
+ "name": "there should be no parse errors"
46
+ }
47
+ ]
48
+ },
49
+ {
50
+ "file_colon_line": "features/step_definitions/gherkin_steps.rb:13",
51
+ "flags": "",
52
+ "source": "^there should be a parse error on (line \\d+)$",
53
+ "steps": [
54
+ {
55
+ "args": [
56
+ {
57
+ "offset": 33,
58
+ "val": "line 1"
59
+ }
60
+ ],
61
+ "name": "there should be a parse error on line 1"
62
+ }
63
+ ]
64
+ },
65
+ {
66
+ "file_colon_line": "features/step_definitions/gherkin_steps.rb:17",
67
+ "flags": "",
68
+ "source": "^there should be parse errors on (lines .*)$",
69
+ "steps": [
70
+ {
71
+ "args": [
72
+ {
73
+ "offset": 32,
74
+ "val": "lines 1 and 2"
75
+ }
76
+ ],
77
+ "name": "there should be parse errors on lines 1 and 2"
78
+ },
79
+ {
80
+ "args": [
81
+ {
82
+ "offset": 32,
83
+ "val": "lines 1 through 3"
84
+ }
85
+ ],
86
+ "name": "there should be parse errors on lines 1 through 3"
87
+ },
88
+ {
89
+ "args": [
90
+ {
91
+ "offset": 32,
92
+ "val": "lines 10 and 17"
93
+ }
94
+ ],
95
+ "name": "there should be parse errors on lines 10 and 17"
96
+ },
97
+ {
98
+ "args": [
99
+ {
100
+ "offset": 32,
101
+ "val": "lines 3 and 5"
102
+ }
103
+ ],
104
+ "name": "there should be parse errors on lines 3 and 5"
105
+ },
106
+ {
107
+ "args": [
108
+ {
109
+ "offset": 32,
110
+ "val": "lines 5, 10 and 12"
111
+ }
112
+ ],
113
+ "name": "there should be parse errors on lines 5, 10 and 12"
114
+ }
115
+ ]
116
+ },
117
+ {
118
+ "file_colon_line": "features/step_definitions/json_formatter_steps.rb:13",
119
+ "flags": "",
120
+ "source": "^a JSON formatter$",
121
+ "steps": [
122
+
123
+ ]
124
+ },
125
+ {
126
+ "file_colon_line": "features/step_definitions/json_formatter_steps.rb:18",
127
+ "flags": "",
128
+ "source": "^the outputted JSON should be:$",
129
+ "steps": [
130
+ {
131
+ "args": [
132
+
133
+ ],
134
+ "name": "the outputted JSON should be:"
135
+ }
136
+ ]
137
+ },
138
+ {
139
+ "file_colon_line": "features/step_definitions/json_parser_steps.rb:5",
140
+ "flags": "",
141
+ "source": "^a PrettyFormatter$",
142
+ "steps": [
143
+
144
+ ]
145
+ },
146
+ {
147
+ "file_colon_line": "features/step_definitions/json_parser_steps.rb:10",
148
+ "flags": "",
149
+ "source": "^a JSON lexer$",
150
+ "steps": [
151
+
152
+ ]
153
+ },
154
+ {
155
+ "file_colon_line": "features/step_definitions/json_parser_steps.rb:14",
156
+ "flags": "",
157
+ "source": "^the following JSON is parsed:$",
158
+ "steps": [
159
+ {
160
+ "args": [
161
+
162
+ ],
163
+ "name": "the following JSON is parsed:"
164
+ }
165
+ ]
166
+ },
167
+ {
168
+ "file_colon_line": "features/step_definitions/json_parser_steps.rb:18",
169
+ "flags": "",
170
+ "source": "^the outputted text should be:$",
171
+ "steps": [
172
+ {
173
+ "args": [
174
+
175
+ ],
176
+ "name": "the outputted text should be:"
177
+ }
178
+ ]
179
+ },
180
+ {
181
+ "file_colon_line": "features/step_definitions/pretty_formatter_steps.rb:50",
182
+ "flags": "",
183
+ "source": "^I have Cucumber's source code next to Gherkin's$",
184
+ "steps": [
185
+ {
186
+ "args": [
187
+
188
+ ],
189
+ "name": "I have Cucumber's source code next to Gherkin's"
190
+ }
191
+ ]
192
+ },
193
+ {
194
+ "file_colon_line": "features/step_definitions/pretty_formatter_steps.rb:55",
195
+ "flags": "",
196
+ "source": "^I find all of the \\.feature files$",
197
+ "steps": [
198
+ {
199
+ "args": [
200
+
201
+ ],
202
+ "name": "I find all of the .feature files"
203
+ }
204
+ ]
205
+ },
206
+ {
207
+ "file_colon_line": "features/step_definitions/pretty_formatter_steps.rb:59",
208
+ "flags": "",
209
+ "source": "^I send each prettified original through the \"([^\"]*)\" machinery$",
210
+ "steps": [
211
+ {
212
+ "args": [
213
+ {
214
+ "offset": 45,
215
+ "val": "json"
216
+ }
217
+ ],
218
+ "name": "I send each prettified original through the \"json\" machinery"
219
+ },
220
+ {
221
+ "args": [
222
+ {
223
+ "offset": 45,
224
+ "val": "pretty"
225
+ }
226
+ ],
227
+ "name": "I send each prettified original through the \"pretty\" machinery"
228
+ }
229
+ ]
230
+ },
231
+ {
232
+ "file_colon_line": "features/step_definitions/pretty_formatter_steps.rb:83",
233
+ "flags": "",
234
+ "source": "^the machinery output should be identical to the prettified original$",
235
+ "steps": [
236
+ {
237
+ "args": [
238
+
239
+ ],
240
+ "name": "the machinery output should be identical to the prettified original"
241
+ }
242
+ ]
243
+ }
244
+ ]
@@ -0,0 +1,8 @@
1
+ Feature: Escaped pipes
2
+ Scenario: They are the future
3
+ Given they have arrived
4
+ | æ | o |
5
+ | a | ø |
6
+ Given they have arrived
7
+ | æ | \|o |
8
+ | \|a | ø\\ |