gherkin 2.2.5-x86-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitattributes +2 -0
- data/.gitignore +11 -0
- data/.mailmap +2 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/Gemfile +5 -0
- data/History.txt +306 -0
- data/LICENSE +20 -0
- data/README.rdoc +59 -0
- data/Rakefile +16 -0
- data/VERSION +1 -0
- data/bin/gherkin +5 -0
- data/build_native_gems.sh +8 -0
- data/cucumber.yml +3 -0
- data/features/escaped_pipes.feature +8 -0
- data/features/feature_parser.feature +237 -0
- data/features/json_formatter.feature +278 -0
- data/features/json_parser.feature +318 -0
- data/features/native_lexer.feature +19 -0
- data/features/parser_with_native_lexer.feature +205 -0
- data/features/pretty_formatter.feature +15 -0
- data/features/step_definitions/eyeball_steps.rb +3 -0
- data/features/step_definitions/gherkin_steps.rb +29 -0
- data/features/step_definitions/json_formatter_steps.rb +28 -0
- data/features/step_definitions/json_parser_steps.rb +20 -0
- data/features/step_definitions/pretty_formatter_steps.rb +82 -0
- data/features/steps_parser.feature +46 -0
- data/features/support/env.rb +38 -0
- data/gherkin.gemspec +59 -0
- data/ikvm/.gitignore +3 -0
- data/java/.gitignore +2 -0
- data/java/src/main/java/gherkin/lexer/i18n/.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 +28 -0
- data/lib/gherkin/formatter/colors.rb +119 -0
- data/lib/gherkin/formatter/escaping.rb +15 -0
- data/lib/gherkin/formatter/filter_formatter.rb +136 -0
- data/lib/gherkin/formatter/json_formatter.rb +72 -0
- data/lib/gherkin/formatter/line_filter.rb +26 -0
- data/lib/gherkin/formatter/model.rb +231 -0
- data/lib/gherkin/formatter/monochrome_format.rb +9 -0
- data/lib/gherkin/formatter/pretty_formatter.rb +174 -0
- data/lib/gherkin/formatter/regexp_filter.rb +21 -0
- data/lib/gherkin/formatter/tag_count_formatter.rb +47 -0
- data/lib/gherkin/formatter/tag_filter.rb +19 -0
- data/lib/gherkin/i18n.rb +180 -0
- data/lib/gherkin/i18n.yml +601 -0
- data/lib/gherkin/json_parser.rb +88 -0
- data/lib/gherkin/lexer/i18n_lexer.rb +47 -0
- data/lib/gherkin/listener/event.rb +45 -0
- data/lib/gherkin/listener/formatter_listener.rb +113 -0
- data/lib/gherkin/native.rb +7 -0
- data/lib/gherkin/native/ikvm.rb +55 -0
- data/lib/gherkin/native/java.rb +55 -0
- data/lib/gherkin/native/null.rb +9 -0
- data/lib/gherkin/parser/meta.txt +5 -0
- data/lib/gherkin/parser/parser.rb +164 -0
- data/lib/gherkin/parser/root.txt +11 -0
- data/lib/gherkin/parser/steps.txt +4 -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 +24 -0
- data/lib/gherkin/tag_expression.rb +62 -0
- data/lib/gherkin/tools.rb +8 -0
- data/lib/gherkin/tools/files.rb +34 -0
- data/lib/gherkin/tools/reformat.rb +20 -0
- data/lib/gherkin/tools/stats.rb +20 -0
- data/lib/gherkin/tools/stats_listener.rb +60 -0
- data/lib/gherkin/version.rb +3 -0
- data/ragel/i18n/.gitignore +1 -0
- data/ragel/lexer.c.rl.erb +459 -0
- data/ragel/lexer.java.rl.erb +224 -0
- data/ragel/lexer.rb.rl.erb +179 -0
- data/ragel/lexer_common.rl.erb +50 -0
- data/spec/gherkin/c_lexer_spec.rb +21 -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/complex.json +143 -0
- data/spec/gherkin/fixtures/complex_for_filtering.feature +60 -0
- data/spec/gherkin/fixtures/complex_with_tags.feature +61 -0
- data/spec/gherkin/fixtures/dos_line_endings.feature +45 -0
- data/spec/gherkin/fixtures/hantu_pisang.feature +35 -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/scenario_outline_with_tags.feature +13 -0
- data/spec/gherkin/fixtures/scenario_without_steps.feature +5 -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 +18 -0
- data/spec/gherkin/formatter/filter_formatter_spec.rb +165 -0
- data/spec/gherkin/formatter/model_spec.rb +15 -0
- data/spec/gherkin/formatter/pretty_formatter_spec.rb +140 -0
- data/spec/gherkin/formatter/spaces.feature +9 -0
- data/spec/gherkin/formatter/tabs.feature +9 -0
- data/spec/gherkin/formatter/tag_count_formatter_spec.rb +30 -0
- data/spec/gherkin/i18n_spec.rb +149 -0
- data/spec/gherkin/java_lexer_spec.rb +20 -0
- data/spec/gherkin/json.rb +5 -0
- data/spec/gherkin/json_parser_spec.rb +67 -0
- data/spec/gherkin/lexer/i18n_lexer_spec.rb +43 -0
- data/spec/gherkin/output_stream_string_io.rb +24 -0
- data/spec/gherkin/parser/parser_spec.rb +16 -0
- data/spec/gherkin/rb_lexer_spec.rb +19 -0
- data/spec/gherkin/sexp_recorder.rb +56 -0
- data/spec/gherkin/shared/lexer_group.rb +592 -0
- data/spec/gherkin/shared/py_string_group.rb +153 -0
- data/spec/gherkin/shared/row_group.rb +120 -0
- data/spec/gherkin/shared/tags_group.rb +54 -0
- data/spec/gherkin/tag_expression_spec.rb +137 -0
- data/spec/spec_helper.rb +68 -0
- data/tasks/bench.rake +184 -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 +102 -0
- data/tasks/cucumber.rake +18 -0
- data/tasks/gems.rake +42 -0
- data/tasks/ikvm.rake +54 -0
- data/tasks/ragel_task.rb +70 -0
- data/tasks/rdoc.rake +9 -0
- data/tasks/release.rake +30 -0
- data/tasks/rspec.rake +8 -0
- metadata +447 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require '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 : Gherkin::Formatter::Argument
|
22
|
+
argument_class.format("I have 10 cukes", Gherkin::Formatter::BracketFormat.new, [Gherkin::Formatter::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,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'gherkin/formatter/colors'
|
3
|
+
|
4
|
+
module Gherkin
|
5
|
+
module Formatter
|
6
|
+
describe Colors do
|
7
|
+
include Gherkin::Formatter::Colors
|
8
|
+
|
9
|
+
it "should colour stuff red" do
|
10
|
+
failed("hello").should == "\e[31mhello\e[0m"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should be possible to specify no colouring" do
|
14
|
+
failed("hello", true).should == "hello"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'stringio'
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'gherkin/parser/parser'
|
5
|
+
require 'gherkin/formatter/filter_formatter'
|
6
|
+
require 'gherkin/formatter/pretty_formatter'
|
7
|
+
|
8
|
+
module Gherkin
|
9
|
+
module Formatter
|
10
|
+
describe FilterFormatter do
|
11
|
+
attr_accessor :file
|
12
|
+
|
13
|
+
before do
|
14
|
+
self.file = 'complex_for_filtering.feature'
|
15
|
+
end
|
16
|
+
|
17
|
+
def verify_filter(filters, *line_ranges)
|
18
|
+
io = StringIO.new
|
19
|
+
pretty_formatter = Gherkin::Formatter::PrettyFormatter.new(io, true)
|
20
|
+
filter_formatter = Gherkin::Formatter::FilterFormatter.new(pretty_formatter, filters)
|
21
|
+
parser = Gherkin::Parser::Parser.new(filter_formatter)
|
22
|
+
|
23
|
+
path = File.dirname(__FILE__) + "/../fixtures/" + file
|
24
|
+
source = File.new(path).read + "# __EOF__"
|
25
|
+
parser.parse(source, path, 0)
|
26
|
+
|
27
|
+
source_lines = source.split("\n")
|
28
|
+
expected = (line_ranges.map do |line_range|
|
29
|
+
source_lines[(line_range.first-1..line_range.last-1)]
|
30
|
+
end.flatten).join("\n").gsub(/# __EOF__/, '')
|
31
|
+
io.string.should == expected
|
32
|
+
end
|
33
|
+
|
34
|
+
context "tags" do
|
35
|
+
it "should filter on feature tag" do
|
36
|
+
verify_filter(['@tag1'], 1..61)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should filter on scenario tag" do
|
40
|
+
verify_filter(['@tag4'], 1..19)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should filter on abother scenario tag" do
|
44
|
+
verify_filter(['@tag3'], 1..37)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should filter on scenario outline tag" do
|
48
|
+
verify_filter(['@more'], 1..14, 46..61)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should filter on first examples tag" do
|
52
|
+
verify_filter(['@neat'], 1..14, 46..55)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should filter on second examples tag" do
|
56
|
+
verify_filter(['@hamster'], 1..14, 46..49, 56..61)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should not replay examples from ignored scenario outline" do
|
60
|
+
self.file = 'scenario_outline_with_tags.feature'
|
61
|
+
verify_filter(['~@wip'], 1..2, 12..14)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "names" do
|
66
|
+
it "should filter on scenario name" do
|
67
|
+
verify_filter([/Reading a Scenario/], 1..19)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should filter on scenario outline name" do
|
71
|
+
verify_filter([/More/], 1..14, 46..61)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should filter on first examples name" do
|
75
|
+
verify_filter([/Neato/], 1..14, 46..55)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should filter on second examples name" do
|
79
|
+
verify_filter([/Rodents/], 1..14, 46..49, 56..61)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should filter on various names" do
|
83
|
+
self.file = 'hantu_pisang.feature'
|
84
|
+
verify_filter([/Pisang/], 1..8, 19..32)
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should filter on background name" do
|
88
|
+
self.file = 'hantu_pisang.feature'
|
89
|
+
verify_filter([/The background/], 1..5)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context "lines" do
|
94
|
+
context "on the same line as feature element keyword" do
|
95
|
+
it "should filter on scenario without line" do
|
96
|
+
self.file = 'scenario_without_steps.feature'
|
97
|
+
verify_filter([3], 1..4)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should filter on scenario line" do
|
101
|
+
verify_filter([16], 1..19)
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should filter on scenario outline line" do
|
105
|
+
verify_filter([47], 1..14, 46..61)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should filter on first examples line" do
|
109
|
+
verify_filter([51], 1..14, 46..55)
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should filter on second examples line" do
|
113
|
+
verify_filter([57], 1..14, 46..49, 56..61)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context "on the same line as step keyword" do
|
118
|
+
it "should filter on step line" do
|
119
|
+
verify_filter([17], 1..19)
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should filter on scenario outline line" do
|
123
|
+
verify_filter([48], 1..14, 46..61)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
context "on examples header line" do
|
128
|
+
it "should filter on first table" do
|
129
|
+
verify_filter([52], 1..14, 46..55)
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should filter on second table" do
|
133
|
+
verify_filter([58], 1..14, 46..49, 56..61)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context "on examples example line" do
|
138
|
+
it "should filter on first table" do
|
139
|
+
verify_filter([53], 1..14, 46..53, 55..55)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
context "on tag line" do
|
144
|
+
it "should filter on first tag" do
|
145
|
+
verify_filter([15], 1..19)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
context "multiline argument" do
|
150
|
+
it "should filter on table line" do
|
151
|
+
verify_filter([36], 1..14, 20..37)
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should filter on first pystring quote" do
|
155
|
+
verify_filter([41], 1..14, 38..45)
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should filter on last pystring quote" do
|
159
|
+
verify_filter([44], 1..14, 38..45)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'gherkin/formatter/model'
|
3
|
+
|
4
|
+
module Gherkin
|
5
|
+
module Formatter
|
6
|
+
module Model
|
7
|
+
describe Tag do
|
8
|
+
it "should be equal when name is equal" do
|
9
|
+
tags = [Tag.new('@x', 1), Tag.new('@y', 2), Tag.new('@x', 3)]
|
10
|
+
tags.to_a.uniq.length.should == 2
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'gherkin/formatter/pretty_formatter'
|
4
|
+
require 'gherkin/formatter/argument'
|
5
|
+
require 'gherkin/formatter/model'
|
6
|
+
require 'gherkin/listener/formatter_listener'
|
7
|
+
require 'stringio'
|
8
|
+
|
9
|
+
module Gherkin
|
10
|
+
module Formatter
|
11
|
+
describe PrettyFormatter do
|
12
|
+
def assert_io(s)
|
13
|
+
actual = @io.string
|
14
|
+
actual.should == s
|
15
|
+
end
|
16
|
+
|
17
|
+
def assert_pretty(input, output=input)
|
18
|
+
[true, false].each do |force_ruby|
|
19
|
+
io = StringIO.new
|
20
|
+
pf = Gherkin::Formatter::PrettyFormatter.new(io, true)
|
21
|
+
parser = Gherkin::Parser::Parser.new(pf, true, "root", force_ruby)
|
22
|
+
parser.parse(input, "test.feature", 0)
|
23
|
+
actual = io.string
|
24
|
+
actual.should == output
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def result(status, error_message, arguments, stepdef_location)
|
29
|
+
Model::Result.new(status, error_message, arguments, stepdef_location)
|
30
|
+
end
|
31
|
+
|
32
|
+
before do
|
33
|
+
@io = StringIO.new
|
34
|
+
@l = Gherkin::Formatter::PrettyFormatter.new(@io, true)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should print comments when scenario is longer" do
|
38
|
+
@l.uri("features/foo.feature")
|
39
|
+
@l.feature(Model::Feature.new([], [], "Feature", "Hello", "World", 1))
|
40
|
+
@l.steps([
|
41
|
+
['Given ', 'some stuff'],
|
42
|
+
['When ', 'foo']
|
43
|
+
])
|
44
|
+
@l.scenario(Model::Scenario.new([], [], "Scenario", "The scenario", "", 4))
|
45
|
+
@l.step(Model::Step.new([], "Given ", "some stuff", 5, nil, result('passed', nil, nil, "features/step_definitions/bar.rb:56")))
|
46
|
+
@l.step(Model::Step.new([], "When ", "foo", 6, nil, result('passed', nil, nil, "features/step_definitions/bar.rb:96")))
|
47
|
+
|
48
|
+
assert_io(%{Feature: Hello
|
49
|
+
World
|
50
|
+
|
51
|
+
Scenario: The scenario # features/foo.feature:4
|
52
|
+
Given some stuff # features/step_definitions/bar.rb:56
|
53
|
+
When foo # features/step_definitions/bar.rb:96
|
54
|
+
})
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should print comments when step is longer" do
|
58
|
+
@l.uri("features/foo.feature")
|
59
|
+
@l.feature(Model::Feature.new([], [], "Feature", "Hello", "World", 1))
|
60
|
+
@l.steps([
|
61
|
+
['Given ', 'some stuff that is longer']
|
62
|
+
])
|
63
|
+
@l.scenario(Model::Scenario.new([], [], "Scenario", "The scenario", "", 4))
|
64
|
+
@l.step(Model::Step.new([], "Given ", "some stuff that is longer", 5, nil, result('passed', nil, nil, "features/step_definitions/bar.rb:56")))
|
65
|
+
|
66
|
+
assert_io(%{Feature: Hello
|
67
|
+
World
|
68
|
+
|
69
|
+
Scenario: The scenario # features/foo.feature:4
|
70
|
+
Given some stuff that is longer # features/step_definitions/bar.rb:56
|
71
|
+
})
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should highlight arguments for regular steps" do
|
75
|
+
step = Model::Step.new([], "Given ", "I have 999 cukes in my belly", 3, nil, result('passed', nil, [Gherkin::Formatter::Argument.new(7, '999')], nil))
|
76
|
+
@l.step(step)
|
77
|
+
assert_io(" Given I have 999 cukes in my belly\n")
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should prettify scenario" do
|
81
|
+
assert_pretty(%{Feature: Feature Description
|
82
|
+
Some preamble
|
83
|
+
|
84
|
+
Scenario: Scenario Description
|
85
|
+
description has multiple lines
|
86
|
+
|
87
|
+
Given there is a step
|
88
|
+
"""
|
89
|
+
with
|
90
|
+
pystrings
|
91
|
+
"""
|
92
|
+
And there is another step
|
93
|
+
| æ | \\|o |
|
94
|
+
| \\|a | ø\\\\ |
|
95
|
+
Then we will see steps
|
96
|
+
})
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
it "should prettify scenario outline with table" do
|
101
|
+
assert_pretty(%{# A feature comment
|
102
|
+
@foo
|
103
|
+
Feature: Feature Description
|
104
|
+
Some preamble
|
105
|
+
on several
|
106
|
+
lines
|
107
|
+
|
108
|
+
# A Scenario Outline comment
|
109
|
+
@bar
|
110
|
+
Scenario Outline: Scenario Ouline Description
|
111
|
+
Given there is a
|
112
|
+
"""
|
113
|
+
string with <foo>
|
114
|
+
"""
|
115
|
+
And a table with
|
116
|
+
| <bar> |
|
117
|
+
| <baz> |
|
118
|
+
|
119
|
+
@zap @boing
|
120
|
+
Examples: Examples Description
|
121
|
+
| foo | bar | baz |
|
122
|
+
| Banana | I | am hungry |
|
123
|
+
| Beer | You | are thirsty |
|
124
|
+
| Bed | They | are tired |
|
125
|
+
})
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should preserve tabs" do
|
129
|
+
assert_pretty(IO.read(File.dirname(__FILE__) + '/tabs.feature'), IO.read(File.dirname(__FILE__) + '/spaces.feature'))
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should escape backslashes and pipes" do
|
133
|
+
io = StringIO.new
|
134
|
+
l = Gherkin::Formatter::PrettyFormatter.new(io, true)
|
135
|
+
l.__send__(:table, [Gherkin::Formatter::Model::Row.new([], ['|', '\\'], nil)])
|
136
|
+
io.string.should == ' | \\| | \\\\ |' + "\n"
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|