gherkin 1.0.30-universal-dotnet
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitattributes +2 -0
- data/.gitignore +9 -0
- data/.mailmap +2 -0
- data/History.txt +187 -0
- data/LICENSE +20 -0
- data/README.rdoc +59 -0
- data/Rakefile +58 -0
- data/VERSION.yml +5 -0
- data/bin/gherkin +5 -0
- data/cucumber.yml +3 -0
- data/features/escaped_pipes.feature +8 -0
- data/features/feature_parser.feature +226 -0
- data/features/native_lexer.feature +19 -0
- data/features/parser_with_native_lexer.feature +205 -0
- data/features/pretty_printer.feature +14 -0
- data/features/step_definitions/eyeball_steps.rb +3 -0
- data/features/step_definitions/gherkin_steps.rb +30 -0
- data/features/step_definitions/pretty_formatter_steps.rb +55 -0
- data/features/steps_parser.feature +46 -0
- data/features/support/env.rb +33 -0
- data/ikvm/.gitignore +3 -0
- data/java/.gitignore +2 -0
- data/java/src/main/java/gherkin/lexer/.gitignore +1 -0
- data/java/src/main/resources/gherkin/.gitignore +1 -0
- data/lib/.gitignore +4 -0
- data/lib/gherkin.rb +2 -0
- data/lib/gherkin/c_lexer.rb +17 -0
- data/lib/gherkin/cli/main.rb +33 -0
- data/lib/gherkin/formatter/argument.rb +27 -0
- data/lib/gherkin/formatter/colors.rb +119 -0
- data/lib/gherkin/formatter/escaping.rb +15 -0
- data/lib/gherkin/formatter/monochrome_format.rb +9 -0
- data/lib/gherkin/formatter/pretty_formatter.rb +168 -0
- data/lib/gherkin/i18n.rb +176 -0
- data/lib/gherkin/i18n.yml +588 -0
- data/lib/gherkin/i18n_lexer.rb +38 -0
- data/lib/gherkin/native.rb +7 -0
- data/lib/gherkin/native/ikvm.rb +55 -0
- data/lib/gherkin/native/java.rb +47 -0
- data/lib/gherkin/native/null.rb +9 -0
- data/lib/gherkin/parser/event.rb +45 -0
- data/lib/gherkin/parser/filter_listener.rb +199 -0
- data/lib/gherkin/parser/meta.txt +5 -0
- data/lib/gherkin/parser/parser.rb +142 -0
- data/lib/gherkin/parser/root.txt +11 -0
- data/lib/gherkin/parser/steps.txt +4 -0
- data/lib/gherkin/parser/tag_expression.rb +50 -0
- data/lib/gherkin/rb_lexer.rb +8 -0
- data/lib/gherkin/rb_lexer/.gitignore +1 -0
- data/lib/gherkin/rb_lexer/README.rdoc +8 -0
- data/lib/gherkin/rubify.rb +18 -0
- data/lib/gherkin/tools.rb +8 -0
- data/lib/gherkin/tools/files.rb +35 -0
- data/lib/gherkin/tools/reformat.rb +19 -0
- data/lib/gherkin/tools/stats.rb +21 -0
- data/lib/gherkin/tools/stats_listener.rb +57 -0
- data/ragel/i18n/.gitignore +1 -0
- data/ragel/lexer.c.rl.erb +425 -0
- data/ragel/lexer.java.rl.erb +216 -0
- data/ragel/lexer.rb.rl.erb +173 -0
- data/ragel/lexer_common.rl.erb +50 -0
- data/spec/gherkin/c_lexer_spec.rb +21 -0
- data/spec/gherkin/csharp_lexer_spec.rb +20 -0
- data/spec/gherkin/fixtures/1.feature +8 -0
- data/spec/gherkin/fixtures/comments_in_table.feature +9 -0
- data/spec/gherkin/fixtures/complex.feature +45 -0
- data/spec/gherkin/fixtures/dos_line_endings.feature +45 -0
- data/spec/gherkin/fixtures/i18n_fr.feature +14 -0
- data/spec/gherkin/fixtures/i18n_no.feature +7 -0
- data/spec/gherkin/fixtures/i18n_zh-CN.feature +9 -0
- data/spec/gherkin/fixtures/simple_with_comments.feature +7 -0
- data/spec/gherkin/fixtures/simple_with_tags.feature +11 -0
- data/spec/gherkin/fixtures/with_bom.feature +3 -0
- data/spec/gherkin/formatter/argument_spec.rb +28 -0
- data/spec/gherkin/formatter/colors_spec.rb +19 -0
- data/spec/gherkin/formatter/pretty_formatter_spec.rb +162 -0
- data/spec/gherkin/formatter/spaces.feature +9 -0
- data/spec/gherkin/formatter/tabs.feature +9 -0
- data/spec/gherkin/i18n_lexer_spec.rb +26 -0
- data/spec/gherkin/i18n_spec.rb +144 -0
- data/spec/gherkin/java_lexer_spec.rb +21 -0
- data/spec/gherkin/parser/filter_listener_spec.rb +390 -0
- data/spec/gherkin/parser/parser_spec.rb +50 -0
- data/spec/gherkin/parser/tag_expression_spec.rb +116 -0
- data/spec/gherkin/rb_lexer_spec.rb +19 -0
- data/spec/gherkin/sexp_recorder.rb +32 -0
- data/spec/gherkin/shared/lexer_spec.rb +550 -0
- data/spec/gherkin/shared/py_string_spec.rb +150 -0
- data/spec/gherkin/shared/row_spec.rb +104 -0
- data/spec/gherkin/shared/tags_spec.rb +50 -0
- data/spec/spec_helper.rb +87 -0
- data/tasks/bench.rake +188 -0
- data/tasks/bench/feature_builder.rb +49 -0
- data/tasks/bench/generated/.gitignore +1 -0
- data/tasks/bench/null_listener.rb +4 -0
- data/tasks/compile.rake +89 -0
- data/tasks/cucumber.rake +26 -0
- data/tasks/gems.rake +45 -0
- data/tasks/ikvm.rake +47 -0
- data/tasks/ragel_task.rb +70 -0
- data/tasks/rdoc.rake +12 -0
- data/tasks/release.rake +26 -0
- data/tasks/rspec.rake +15 -0
- metadata +257 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
if defined?(RUBY_ENGINE) && RUBY_ENGINE == "ironruby"
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
4
|
+
|
5
|
+
module Gherkin
|
6
|
+
module Lexer
|
7
|
+
describe "C# Lexer" do
|
8
|
+
before do
|
9
|
+
@listener = Gherkin::SexpRecorder.new
|
10
|
+
@lexer = Gherkin::Lexer.csharp['en'].new(@listener)
|
11
|
+
end
|
12
|
+
|
13
|
+
it_should_behave_like "a Gherkin lexer"
|
14
|
+
it_should_behave_like "a Gherkin lexer lexing tags"
|
15
|
+
it_should_behave_like "a Gherkin lexer lexing py_strings"
|
16
|
+
it_should_behave_like "a Gherkin lexer lexing rows"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#Comment on line 1
|
2
|
+
#Comment on line 2
|
3
|
+
@tag1 @tag2
|
4
|
+
Feature: Feature Text
|
5
|
+
In order to test multiline forms
|
6
|
+
As a ragel writer
|
7
|
+
I need to check for complex combinations
|
8
|
+
|
9
|
+
#Comment on line 9
|
10
|
+
|
11
|
+
#Comment on line 11
|
12
|
+
|
13
|
+
Background:
|
14
|
+
Given this is a background step
|
15
|
+
And this is another one
|
16
|
+
|
17
|
+
@tag3 @tag4
|
18
|
+
Scenario: Reading a Scenario
|
19
|
+
Given there is a step
|
20
|
+
But not another step
|
21
|
+
|
22
|
+
@tag3
|
23
|
+
Scenario: Reading a second scenario
|
24
|
+
With two lines of text
|
25
|
+
#Comment on line 24
|
26
|
+
Given a third step with a table
|
27
|
+
|a|b|
|
28
|
+
|c|d|
|
29
|
+
|e|f|
|
30
|
+
And I am still testing things
|
31
|
+
|g|h|
|
32
|
+
|e|r|
|
33
|
+
|k|i|
|
34
|
+
|n||
|
35
|
+
And I am done testing these tables
|
36
|
+
#Comment on line 29
|
37
|
+
Then I am happy
|
38
|
+
|
39
|
+
Scenario: Hammerzeit
|
40
|
+
Given All work and no play
|
41
|
+
"""
|
42
|
+
Makes Homer something something
|
43
|
+
And something else
|
44
|
+
"""
|
45
|
+
Then crazy
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#Comment on line 1
|
2
|
+
#Comment on line 2
|
3
|
+
@tag1 @tag2
|
4
|
+
Feature: Feature Text
|
5
|
+
In order to test multiline forms
|
6
|
+
As a ragel writer
|
7
|
+
I need to check for complex combinations
|
8
|
+
|
9
|
+
#Comment on line 9
|
10
|
+
|
11
|
+
#Comment on line 11
|
12
|
+
|
13
|
+
Background:
|
14
|
+
Given this is a background step
|
15
|
+
And this is another one
|
16
|
+
|
17
|
+
@tag3 @tag4
|
18
|
+
Scenario: Reading a Scenario
|
19
|
+
Given there is a step
|
20
|
+
But not another step
|
21
|
+
|
22
|
+
@tag3
|
23
|
+
Scenario: Reading a second scenario
|
24
|
+
With two lines of text
|
25
|
+
#Comment on line 24
|
26
|
+
Given a third step with a table
|
27
|
+
|a|b|
|
28
|
+
|c|d|
|
29
|
+
|e|f|
|
30
|
+
And I am still testing things
|
31
|
+
|g|h|
|
32
|
+
|e|r|
|
33
|
+
|k|i|
|
34
|
+
|n||
|
35
|
+
And I am done testing these tables
|
36
|
+
#Comment on line 29
|
37
|
+
Then I am happy
|
38
|
+
|
39
|
+
Scenario: Hammerzeit
|
40
|
+
Given All work and no play
|
41
|
+
"""
|
42
|
+
Makes Homer something something
|
43
|
+
And something else
|
44
|
+
"""
|
45
|
+
Then crazy
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#language:fr
|
2
|
+
Fonctionnalité: Addition
|
3
|
+
Plan du scénario: Addition de produits dérivés
|
4
|
+
Soit une calculatrice
|
5
|
+
Etant donné qu'on tape <a>
|
6
|
+
Et qu'on tape <b>
|
7
|
+
Lorsqu'on tape additionner
|
8
|
+
Alors le résultat doit être <somme>
|
9
|
+
|
10
|
+
Exemples:
|
11
|
+
| a | b | somme |
|
12
|
+
| 2 | 2 | 4 |
|
13
|
+
| 2 | 3 | 5 |
|
14
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
3
|
+
require 'gherkin/formatter/argument'
|
4
|
+
|
5
|
+
module Gherkin
|
6
|
+
module Formatter
|
7
|
+
class BracketFormat
|
8
|
+
class << self
|
9
|
+
def new
|
10
|
+
defined?(JRUBY_VERSION) ? ::Java::GherkinFormatter::ArgumentFormat.new("[", "]") : super
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def format_argument(s)
|
15
|
+
"[#{s}]"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe Argument do
|
20
|
+
it "should replace one arg" do
|
21
|
+
argument_class = defined?(JRUBY_VERSION) ? ::Java::GherkinFormatter::Argument : Argument
|
22
|
+
argument_class.format("I have 10 cukes", BracketFormat.new, [Argument.new(7, '10')]).should == "I have [10] cukes"
|
23
|
+
end
|
24
|
+
|
25
|
+
# TODO: Add this spec: http://github.com/alg/cucumber/commit/33188e9db51f59ced74c4861524d7b2e69454630
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
require 'gherkin/formatter/pretty_formatter'
|
3
|
+
|
4
|
+
|
5
|
+
module Gherkin
|
6
|
+
module Formatter
|
7
|
+
describe Colors do
|
8
|
+
include Colors
|
9
|
+
|
10
|
+
it "should colour stuff red" do
|
11
|
+
failed("hello").should == "\e[31mhello\e[0m"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should be possible to specify no colouring" do
|
15
|
+
failed("hello", true).should == "hello"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,162 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
3
|
+
require 'gherkin/formatter/pretty_formatter'
|
4
|
+
require 'gherkin/formatter/argument'
|
5
|
+
require 'stringio'
|
6
|
+
|
7
|
+
module Gherkin
|
8
|
+
module Formatter
|
9
|
+
describe PrettyFormatter do
|
10
|
+
def assert_io(s)
|
11
|
+
@io.rewind
|
12
|
+
actual = @io.read
|
13
|
+
actual.should == s
|
14
|
+
end
|
15
|
+
|
16
|
+
def assert_pretty(input, output=input)
|
17
|
+
[true, false].each do |force_ruby|
|
18
|
+
io = StringIO.new
|
19
|
+
l = PrettyFormatter.new(io, true)
|
20
|
+
parser = Gherkin::Parser::Parser.new(l, true, "root")
|
21
|
+
lexer = Gherkin::I18nLexer.new(parser, force_ruby)
|
22
|
+
lexer.scan(input)
|
23
|
+
io.rewind
|
24
|
+
actual = io.read
|
25
|
+
actual.should == output
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
before do
|
30
|
+
@io = StringIO.new
|
31
|
+
@l = PrettyFormatter.new(@io, true)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should print comments when scenario is longer" do
|
35
|
+
@l.feature("Feature", "Hello\nWorld", 1)
|
36
|
+
@l.steps([
|
37
|
+
['Given ', 'some stuff'],
|
38
|
+
['When ', 'foo']
|
39
|
+
])
|
40
|
+
@l.scenario("Scenario", "The scenario", 4, "features/foo.feature:4")
|
41
|
+
@l.step("Given ", "some stuff", 5, nil, nil, nil, "features/step_definitions/bar.rb:56")
|
42
|
+
@l.step("When ", "foo", 6, nil, nil, nil, "features/step_definitions/bar.rb:96")
|
43
|
+
|
44
|
+
assert_io(%{Feature: Hello
|
45
|
+
World
|
46
|
+
|
47
|
+
Scenario: The scenario # features/foo.feature:4
|
48
|
+
Given some stuff # features/step_definitions/bar.rb:56
|
49
|
+
When foo # features/step_definitions/bar.rb:96
|
50
|
+
})
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should print comments when step is longer" do
|
54
|
+
@l.feature("Feature", "Hello\nWorld", 1)
|
55
|
+
@l.steps([
|
56
|
+
['Given ', 'some stuff that is longer']
|
57
|
+
])
|
58
|
+
@l.scenario("Scenario", "The scenario", 4, "features/foo.feature:4")
|
59
|
+
@l.step("Given ", "some stuff that is longer", 5, nil, nil, nil, "features/step_definitions/bar.rb:56")
|
60
|
+
|
61
|
+
assert_io(%{Feature: Hello
|
62
|
+
World
|
63
|
+
|
64
|
+
Scenario: The scenario # features/foo.feature:4
|
65
|
+
Given some stuff that is longer # features/step_definitions/bar.rb:56
|
66
|
+
})
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should print ANSI coloured steps" do
|
70
|
+
@l.feature("Feature", "Hello\nWorld", 1)
|
71
|
+
@l.steps([
|
72
|
+
['Given ', 'some stuff that is longer']
|
73
|
+
])
|
74
|
+
@l.scenario("Scenario", "The scenario", 4, "features/foo.feature:4")
|
75
|
+
@l.step("Given ", "some stuff that is longer", 5, nil, nil, nil, "features/step_definitions/bar.rb:56")
|
76
|
+
|
77
|
+
assert_io(%{Feature: Hello
|
78
|
+
World
|
79
|
+
|
80
|
+
Scenario: The scenario # features/foo.feature:4
|
81
|
+
Given some stuff that is longer # features/step_definitions/bar.rb:56
|
82
|
+
})
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should prettify a whole table with padding (typically ANSI)" do
|
86
|
+
@l.row(%w(a bb), 1)
|
87
|
+
@l.row(%w(ccc d), 2)
|
88
|
+
@l.row(%w(ee ffff), 3)
|
89
|
+
@l.flush_table
|
90
|
+
|
91
|
+
assert_io(
|
92
|
+
" | a | bb |\n" +
|
93
|
+
" | ccc | d |\n" +
|
94
|
+
" | ee | ffff |\n"
|
95
|
+
)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should highlight arguments for regular steps" do
|
99
|
+
passed = defined?(JRUBY_VERSION) ? 'passed' : :passed
|
100
|
+
@l.step("Given ", "I have 999 cukes in my belly", 3, passed, nil, [Gherkin::Formatter::Argument.new(7, '999')], nil)
|
101
|
+
assert_io(" Given I have 999 cukes in my belly\n")
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should prettify scenario" do
|
105
|
+
assert_pretty(%{Feature: Feature Description
|
106
|
+
Some preamble
|
107
|
+
|
108
|
+
Scenario: Scenario Description
|
109
|
+
Given there is a step
|
110
|
+
"""
|
111
|
+
with
|
112
|
+
pystrings
|
113
|
+
"""
|
114
|
+
And there is another step
|
115
|
+
| æ | \\|o |
|
116
|
+
| \\|a | ø\\\\ |
|
117
|
+
Then we will see steps
|
118
|
+
})
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
it "should prettify scenario outline with table" do
|
123
|
+
assert_pretty(%{# A feature comment
|
124
|
+
@foo
|
125
|
+
Feature: Feature Description
|
126
|
+
Some preamble
|
127
|
+
|
128
|
+
# A Scenario Outline comment
|
129
|
+
@bar
|
130
|
+
Scenario Outline: Scenario Ouline Description
|
131
|
+
Given there is a
|
132
|
+
"""
|
133
|
+
string with <foo>
|
134
|
+
"""
|
135
|
+
And a table with
|
136
|
+
| <bar> |
|
137
|
+
| <baz> |
|
138
|
+
|
139
|
+
@zap @boing
|
140
|
+
Examples: Examples Description
|
141
|
+
| foo | bar | baz |
|
142
|
+
| Banana | I | am hungry |
|
143
|
+
| Beer | You | are thirsty |
|
144
|
+
| Bed | They | are tired |
|
145
|
+
})
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should preserve tabs" do
|
149
|
+
assert_pretty(IO.read(File.dirname(__FILE__) + '/tabs.feature'), IO.read(File.dirname(__FILE__) + '/spaces.feature'))
|
150
|
+
end
|
151
|
+
|
152
|
+
it "should escape backslashes and pipes" do
|
153
|
+
io = StringIO.new
|
154
|
+
l = PrettyFormatter.new(io, true)
|
155
|
+
l.row(['|', '\\'], 1)
|
156
|
+
l.flush_table
|
157
|
+
io.rewind
|
158
|
+
io.read.should == ' | \\| | \\\\ |' + "\n"
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
3
|
+
|
4
|
+
module Gherkin
|
5
|
+
describe I18nLexer do
|
6
|
+
before do
|
7
|
+
@lexer = I18nLexer.new(SexpRecorder.new, false)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should store the i18n language of the last scanned feature" do
|
11
|
+
@lexer.scan("# language: fr\n")
|
12
|
+
@lexer.i18n_language.iso_code.should == "fr"
|
13
|
+
@lexer.scan("# language: no\n")
|
14
|
+
@lexer.i18n_language.iso_code.should == "no"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should use English i18n by default" do
|
18
|
+
@lexer.scan("Feature: foo\n")
|
19
|
+
@lexer.i18n_language.iso_code.should == "en"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should === its ruby class, even when the impl is Java" do
|
23
|
+
I18nLexer.should === I18nLexer.new(SexpRecorder.new, true)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|