cucumber 0.6.4 → 0.7.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +11 -0
- data/Rakefile +3 -5
- data/VERSION.yml +3 -3
- data/cucumber.gemspec +35 -55
- data/cucumber.yml +3 -2
- data/examples/i18n/Rakefile +1 -0
- data/examples/i18n/en-lol/features/step_definitions/cucumbrz_steps.rb +1 -1
- data/examples/i18n/eo/.gitignore +1 -0
- data/examples/i18n/eo/Rakefile +6 -0
- data/examples/i18n/eo/features/adicio.feature +17 -0
- data/examples/i18n/eo/features/divido.feature +10 -0
- data/examples/i18n/eo/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/eo/lib/calculator.rb +14 -0
- data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +1 -1
- data/examples/i18n/ru/features/division.feature +1 -1
- data/examples/i18n/uk/Rakefile +6 -0
- data/examples/i18n/uk/features/addition.feature +11 -0
- data/examples/i18n/uk/features/consecutive_calculations.feature +17 -0
- data/examples/i18n/uk/features/division.feature +16 -0
- data/examples/i18n/uk/features/step_definitons/calculator_steps.rb +19 -0
- data/examples/i18n/uk/features/support/env.rb +5 -0
- data/examples/i18n/uk/features/support/world.rb +8 -0
- data/examples/i18n/uk/lib/calculator.rb +24 -0
- data/examples/i18n/uz/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/sinatra/features/add.feature +1 -1
- data/examples/sinatra/features/step_definitions/add_steps.rb +1 -1
- data/examples/sinatra/features/support/env.rb +2 -19
- data/examples/sinatra/views/add.erb +7 -5
- data/features/announce.feature +46 -39
- data/features/background.feature +3 -0
- data/features/call_many_steps.feature +1 -1
- data/features/cucumber_cli_outlines.feature +12 -0
- data/features/drb_server_integration.feature +1 -1
- data/features/exception_in_after_block.feature +3 -0
- data/features/exception_in_after_step_block.feature +3 -0
- data/features/html_formatter/a.html +29 -29
- data/features/language_help.feature +57 -52
- data/features/multiline_names.feature +1 -0
- data/features/step_definitions/cucumber_steps.rb +2 -1
- data/features/usage_and_stepdefs_formatter.feature +30 -30
- data/features/wire_protocol.feature +12 -9
- data/features/wire_protocol_table_diffing.feature +8 -6
- data/features/wire_protocol_timeouts.feature +5 -4
- data/gem_tasks/treetop.rake +13 -0
- data/lib/autotest/cucumber_mixin.rb +1 -1
- data/lib/cucumber/ast.rb +1 -0
- data/lib/cucumber/ast/background.rb +14 -4
- data/lib/cucumber/ast/examples.rb +2 -0
- data/lib/cucumber/ast/feature.rb +26 -5
- data/lib/cucumber/ast/feature_element.rb +18 -9
- data/lib/cucumber/ast/outline_table.rb +13 -1
- data/lib/cucumber/ast/py_string.rb +26 -9
- data/lib/cucumber/ast/scenario.rb +13 -7
- data/lib/cucumber/ast/scenario_outline.rb +18 -6
- data/lib/cucumber/ast/step.rb +4 -4
- data/lib/cucumber/ast/step_invocation.rb +5 -2
- data/lib/cucumber/ast/table.rb +26 -1
- data/lib/cucumber/ast/tags.rb +3 -1
- data/lib/cucumber/ast/tree_walker.rb +2 -18
- data/lib/cucumber/cli/configuration.rb +2 -2
- data/lib/cucumber/cli/options.rb +16 -21
- data/lib/cucumber/feature_file.rb +25 -7
- data/lib/cucumber/formatter/ansicolor.rb +6 -1
- data/lib/cucumber/formatter/console.rb +4 -3
- data/lib/cucumber/formatter/html.rb +8 -5
- data/lib/cucumber/formatter/junit.rb +5 -4
- data/lib/cucumber/formatter/pdf.rb +2 -3
- data/lib/cucumber/formatter/pretty.rb +5 -5
- data/lib/cucumber/formatter/usage.rb +2 -2
- data/lib/cucumber/parser.rb +0 -6
- data/lib/cucumber/parser/gherkin_builder.rb +142 -0
- data/lib/cucumber/platform.rb +0 -2
- data/lib/cucumber/rb_support/rb_language.rb +7 -12
- data/lib/cucumber/step_mother.rb +4 -26
- data/spec/cucumber/ast/background_spec.rb +0 -1
- data/spec/cucumber/ast/feature_factory.rb +2 -4
- data/spec/cucumber/ast/feature_spec.rb +0 -2
- data/spec/cucumber/ast/py_string_spec.rb +2 -13
- data/spec/cucumber/ast/scenario_outline_spec.rb +0 -1
- data/spec/cucumber/ast/scenario_spec.rb +0 -1
- data/spec/cucumber/ast/step_spec.rb +1 -1
- data/spec/cucumber/ast/table_spec.rb +2 -2
- data/spec/cucumber/cli/main_spec.rb +1 -1
- data/spec/cucumber/cli/options_spec.rb +2 -2
- data/spec/cucumber/formatter/html_spec.rb +20 -1
- data/spec/cucumber/formatter/junit_spec.rb +1 -0
- data/spec/cucumber/formatter/spec_helper.rb +7 -5
- data/spec/cucumber/rb_support/rb_step_definition_spec.rb +0 -1
- data/spec/cucumber/step_mother_spec.rb +2 -2
- data/spec/spec_helper.rb +0 -1
- metadata +67 -93
- data/lib/cucumber/cli/language_help_formatter.rb +0 -72
- data/lib/cucumber/filter.rb +0 -43
- data/lib/cucumber/languages.yml +0 -536
- data/lib/cucumber/parser/common.rb +0 -182
- data/lib/cucumber/parser/common.tt +0 -21
- data/lib/cucumber/parser/feature.rb +0 -1591
- data/lib/cucumber/parser/feature.tt +0 -287
- data/lib/cucumber/parser/i18n.tt +0 -35
- data/lib/cucumber/parser/natural_language.rb +0 -118
- data/lib/cucumber/parser/py_string.rb +0 -285
- data/lib/cucumber/parser/py_string.tt +0 -45
- data/lib/cucumber/parser/table.rb +0 -314
- data/lib/cucumber/parser/table.tt +0 -60
- data/lib/cucumber/parser/treetop_ext.rb +0 -54
- data/lib/cucumber/tag_expression.rb +0 -41
- data/spec/cucumber/ast/feature_element_spec.rb +0 -41
- data/spec/cucumber/ast/step_collection_spec.rb +0 -17
- data/spec/cucumber/parser/feature_parser_spec.rb +0 -400
- data/spec/cucumber/parser/table_parser_spec.rb +0 -52
- data/spec/cucumber/tag_expression_spec.rb +0 -125
- data/spec/cucumber/treetop_parser/empty_feature.feature +0 -4
- data/spec/cucumber/treetop_parser/empty_scenario.feature +0 -9
- data/spec/cucumber/treetop_parser/empty_scenario_outline.feature +0 -3
- data/spec/cucumber/treetop_parser/fit_scenario.feature +0 -8
- data/spec/cucumber/treetop_parser/given_scenario.feature +0 -9
- data/spec/cucumber/treetop_parser/invalid_scenario_outlines.feature +0 -7
- data/spec/cucumber/treetop_parser/multiline_steps.feature +0 -17
- data/spec/cucumber/treetop_parser/multiple_tables.feature +0 -27
- data/spec/cucumber/treetop_parser/scenario_outline.feature +0 -16
- data/spec/cucumber/treetop_parser/spaces.feature +0 -12
- data/spec/cucumber/treetop_parser/test_dos.feature +0 -25
- data/spec/cucumber/treetop_parser/with_comments.feature +0 -23
- data/spec/cucumber/treetop_parser/with_tags.feature +0 -18
@@ -1,41 +0,0 @@
|
|
1
|
-
module Cucumber
|
2
|
-
class TagExpression
|
3
|
-
attr_reader :limits
|
4
|
-
|
5
|
-
def self.parse(tag_expressions)
|
6
|
-
tag_expressions.inject(TagExpression.new) { |e, expr| e.add(expr.strip.split(/\s*,\s*/)); e }
|
7
|
-
end
|
8
|
-
|
9
|
-
def initialize
|
10
|
-
@ands = []
|
11
|
-
@limits = {}
|
12
|
-
end
|
13
|
-
|
14
|
-
def add(tags)
|
15
|
-
negatives, positives = tags.partition{|tag| tag =~ /^~/}
|
16
|
-
positive_limits = Hash[*positives.map{|positive| tag, limit = positive.split(':'); [tag, limit ? limit.to_i : nil]}.flatten]
|
17
|
-
@limits.merge!(positive_limits)
|
18
|
-
@ands << (negatives + positive_limits.keys)
|
19
|
-
end
|
20
|
-
|
21
|
-
def eval(tags)
|
22
|
-
return true if @ands.flatten.empty?
|
23
|
-
vars = Hash[*tags.map{|tag| [tag, true]}.flatten]
|
24
|
-
!!Kernel.eval(ruby_expression)
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def ruby_expression
|
30
|
-
"(" + @ands.map do |ors|
|
31
|
-
ors.map do |tag|
|
32
|
-
if tag =~ /^~(.*)/
|
33
|
-
"!vars['#{$1}']"
|
34
|
-
else
|
35
|
-
"vars['#{tag}']"
|
36
|
-
end
|
37
|
-
end.join("||")
|
38
|
-
end.join(")&&(") + ")"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
-
require 'cucumber/step_mother'
|
3
|
-
require 'cucumber/ast'
|
4
|
-
|
5
|
-
module Cucumber
|
6
|
-
module Ast
|
7
|
-
describe FeatureElement do
|
8
|
-
include FeatureElement
|
9
|
-
|
10
|
-
describe "with multiline names" do
|
11
|
-
it "should select the longest line as the text length" do
|
12
|
-
@keyword = "key"
|
13
|
-
@name = "short\nvery longer\ntiny"
|
14
|
-
text_length.should == 11 + Step::INDENT - 1
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should add keyword to first lines length" do
|
18
|
-
@keyword = "key"
|
19
|
-
@name = "short\nvery longer\ntiny"
|
20
|
-
|
21
|
-
first_line_length.should == (@keyword.jlength) + (first_line_name_length = 5)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "with empty name" do
|
26
|
-
it "should only return the length of the keyword" do
|
27
|
-
@name = ""
|
28
|
-
@keyword = "key"
|
29
|
-
|
30
|
-
text_length.should == 3
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should support checking if its name matches a list of regexps" do
|
35
|
-
@name = 'test'
|
36
|
-
matches_scenario_names?([/es/]).should be_true
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
-
|
3
|
-
module Cucumber
|
4
|
-
module Ast
|
5
|
-
describe StepCollection do
|
6
|
-
it "should convert And to Given in snippets" do
|
7
|
-
s1 = Step.new(1, 'Given', 'cukes')
|
8
|
-
s2 = Step.new(2, 'And', 'turnips')
|
9
|
-
s1.stub!(:language).and_return(Cucumber::Parser::NaturalLanguage.get(nil, 'en'))
|
10
|
-
s2.stub!(:language).and_return(Cucumber::Parser::NaturalLanguage.get(nil, 'en'))
|
11
|
-
c = StepCollection.new([s1, s2])
|
12
|
-
actual_keywords = c.step_invocations.map{|i| i.actual_keyword}
|
13
|
-
actual_keywords.should == %w{Given Given}
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,400 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
-
require 'cucumber/parser/natural_language'
|
3
|
-
|
4
|
-
module Cucumber
|
5
|
-
module Parser
|
6
|
-
describe Feature do
|
7
|
-
before do
|
8
|
-
@step_mother = Cucumber::StepMother.new
|
9
|
-
@parser = Cucumber::Parser::NaturalLanguage.get(@step_mother, 'en').parser
|
10
|
-
end
|
11
|
-
|
12
|
-
after do
|
13
|
-
NaturalLanguage.instance_variable_set(:@languages, nil) # So that new StepMothers can be created and have adverbs registered
|
14
|
-
end
|
15
|
-
|
16
|
-
def parse(text)
|
17
|
-
feature = @parser.parse_or_fail(text)
|
18
|
-
end
|
19
|
-
|
20
|
-
def parse_file(file)
|
21
|
-
Cucumber::FeatureFile.new(File.dirname(__FILE__) + "/../treetop_parser/" + file).parse(@step_mother, {})
|
22
|
-
end
|
23
|
-
|
24
|
-
def parse_example_file(file)
|
25
|
-
Cucumber::FeatureFile.new(File.dirname(__FILE__) + "/../../../examples/" + file).parse(@step_mother, {})
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "Comments" do
|
29
|
-
it "should parse a file with only a one line comment" do
|
30
|
-
parse(%{# My comment
|
31
|
-
Feature: hi
|
32
|
-
}).to_sexp.should ==
|
33
|
-
[:feature, nil, "Feature: hi",
|
34
|
-
[:comment, "# My comment\n"]]
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should parse a file with only a multiline comment" do
|
38
|
-
parse(%{# Hello
|
39
|
-
# World
|
40
|
-
Feature: hi
|
41
|
-
}).to_sexp.should ==
|
42
|
-
[:feature, nil, "Feature: hi",
|
43
|
-
[:comment, "# Hello\n# World\n"]]
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should parse a file with no comments" do
|
47
|
-
parse("Feature: hi\n").to_sexp.should ==
|
48
|
-
[:feature, nil, "Feature: hi"]
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should parse a file with only a multiline comment with newlines" do
|
52
|
-
parse("# Hello\n\n# World\n").to_sexp.should ==
|
53
|
-
[:feature, nil, "",
|
54
|
-
[:comment, "# Hello\n\n# World\n"]]
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should not consume comments as part of a multiline name" do
|
58
|
-
parse("Feature: hi\n Scenario: test\n\n#hello\n Scenario: another").to_sexp.should ==
|
59
|
-
[:feature, nil, "Feature: hi",
|
60
|
-
[:scenario, 2, "Scenario:", "test"],
|
61
|
-
[:scenario, 5, "Scenario:", "another",
|
62
|
-
[:comment, "#hello\n "]]]
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe "Tags" do
|
67
|
-
it "should parse a file with tags on a feature" do
|
68
|
-
parse("# My comment\n@hello @world Feature: hi\n").to_sexp.should ==
|
69
|
-
[:feature, nil, "Feature: hi",
|
70
|
-
[:comment, "# My comment\n"],
|
71
|
-
[:tag, "@hello"],
|
72
|
-
[:tag, "@world"]]
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should not take the tags as part of a multiline name feature element" do
|
76
|
-
parse("Feature: hi\n Scenario: test\n\n@hello Scenario: another").to_sexp.should ==
|
77
|
-
[:feature, nil, "Feature: hi",
|
78
|
-
[:scenario, 2, "Scenario:", "test"],
|
79
|
-
[:scenario, 4, "Scenario:", "another",
|
80
|
-
[:tag, "@hello"]]]
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should parse a file with tags on a scenario" do
|
84
|
-
parse(%{# FC
|
85
|
-
@ft
|
86
|
-
Feature: hi
|
87
|
-
|
88
|
-
@st1 @st2
|
89
|
-
Scenario: First
|
90
|
-
Given Pepper
|
91
|
-
|
92
|
-
@st3
|
93
|
-
@st4 @ST5 @#^%&ST6**!
|
94
|
-
Scenario: Second}).to_sexp.should ==
|
95
|
-
[:feature, nil, "Feature: hi",
|
96
|
-
[:comment, "# FC\n "],
|
97
|
-
[:tag, "@ft"],
|
98
|
-
[:scenario, 6, 'Scenario:', 'First',
|
99
|
-
[:tag, "@st1"], [:tag, "@st2"],
|
100
|
-
[:step_invocation, 7, "Given", "Pepper"]
|
101
|
-
],
|
102
|
-
[:scenario, 11, 'Scenario:', 'Second',
|
103
|
-
[:tag, "@st3"], [:tag, "@st4"], [:tag, "@ST5"], [:tag, "@#^%&ST6**!"]]]
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
describe "Background" do
|
108
|
-
it "should have steps" do
|
109
|
-
parse("Feature: Hi\nBackground:\nGiven I am a step\n").to_sexp.should ==
|
110
|
-
[:feature, nil, "Feature: Hi",
|
111
|
-
[:background, 2, "Background:",
|
112
|
-
[:step, 3, "Given", "I am a step"]]]
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should allow multiline names" do
|
116
|
-
parse(%{Feature: Hi
|
117
|
-
Background: It is my ambition to say
|
118
|
-
in ten sentences
|
119
|
-
what others say
|
120
|
-
in a whole book.
|
121
|
-
Given I am a step}).to_sexp.should ==
|
122
|
-
[:feature, nil, "Feature: Hi",
|
123
|
-
[:background, 2, "Background:", "It is my ambition to say\nin ten sentences\nwhat others say\nin a whole book.",
|
124
|
-
[:step, 6, "Given", "I am a step"]]]
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
describe "Scenarios" do
|
129
|
-
it "can be empty" do
|
130
|
-
parse("Feature: Hi\n\nScenario: Hello\n").to_sexp.should ==
|
131
|
-
[:feature, nil, "Feature: Hi",
|
132
|
-
[:scenario, 3, "Scenario:", "Hello"]]
|
133
|
-
end
|
134
|
-
|
135
|
-
it "should allow whitespace lines after the Scenario line" do
|
136
|
-
parse(%{Feature: Foo
|
137
|
-
|
138
|
-
Scenario: bar
|
139
|
-
|
140
|
-
Given baz})
|
141
|
-
end
|
142
|
-
|
143
|
-
it "should have steps" do
|
144
|
-
parse("Feature: Hi\nScenario: Hello\nGiven I am a step\n").to_sexp.should ==
|
145
|
-
[:feature, nil, "Feature: Hi",
|
146
|
-
[:scenario, 2, "Scenario:", "Hello",
|
147
|
-
[:step_invocation, 3, "Given", "I am a step"]]]
|
148
|
-
end
|
149
|
-
|
150
|
-
it "should have steps with inline table" do
|
151
|
-
parse(%{Feature: Hi
|
152
|
-
Scenario: Hello
|
153
|
-
Given I have a table
|
154
|
-
|a|b|
|
155
|
-
}).to_sexp.should ==
|
156
|
-
[:feature, nil, "Feature: Hi",
|
157
|
-
[:scenario, 2, "Scenario:", "Hello",
|
158
|
-
[:step_invocation, 3, "Given", "I have a table",
|
159
|
-
[:table,
|
160
|
-
[:row, 4,
|
161
|
-
[:cell, "a"],
|
162
|
-
[:cell, "b"]]]]]]
|
163
|
-
end
|
164
|
-
|
165
|
-
it "should have steps with inline py_string" do
|
166
|
-
parse(%{Feature: Hi
|
167
|
-
Scenario: Hello
|
168
|
-
Given I have a string
|
169
|
-
|
170
|
-
|
171
|
-
"""
|
172
|
-
hello
|
173
|
-
world
|
174
|
-
"""
|
175
|
-
|
176
|
-
}).to_sexp.should ==
|
177
|
-
[:feature, nil, "Feature: Hi",
|
178
|
-
[:scenario, 2, "Scenario:", "Hello",
|
179
|
-
[:step_invocation, 3, "Given", "I have a string",
|
180
|
-
[:py_string, "hello\nworld"]]]]
|
181
|
-
end
|
182
|
-
|
183
|
-
it "should allow multiline names" do
|
184
|
-
parse(%{Feature: Hi
|
185
|
-
Scenario: It is my ambition to say
|
186
|
-
in ten sentences
|
187
|
-
what others say
|
188
|
-
in a whole book.
|
189
|
-
Given I am a step
|
190
|
-
|
191
|
-
}).to_sexp.should ==
|
192
|
-
[:feature, nil, "Feature: Hi",
|
193
|
-
[:scenario, 2, "Scenario:", "It is my ambition to say\nin ten sentences\nwhat others say\nin a whole book.",
|
194
|
-
[:step_invocation, 6, "Given", "I am a step"]]]
|
195
|
-
end
|
196
|
-
|
197
|
-
it "should ignore gherkin keywords which are parts of other words in the name" do
|
198
|
-
parse(%{Feature: Parser bug
|
199
|
-
Scenario: I have a Button
|
200
|
-
Buttons are great
|
201
|
-
Given I have it
|
202
|
-
}).to_sexp.should ==
|
203
|
-
[:feature, nil, "Feature: Parser bug",
|
204
|
-
[:scenario, 2, "Scenario:", "I have a Button\nButtons are great",
|
205
|
-
[:step_invocation, 4, "Given", "I have it"]]]
|
206
|
-
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
describe "Scenario Outlines" do
|
211
|
-
it "can be empty" do
|
212
|
-
parse(%{Feature: Hi
|
213
|
-
Scenario Outline: Hello
|
214
|
-
Given a <what> cucumber
|
215
|
-
Examples:
|
216
|
-
|what|
|
217
|
-
|green|
|
218
|
-
}).to_sexp.should ==
|
219
|
-
[:feature, nil, "Feature: Hi",
|
220
|
-
[:scenario_outline, "Scenario Outline:", "Hello",
|
221
|
-
[:step, 3, "Given", "a <what> cucumber"],
|
222
|
-
[:examples, "Examples:", "",
|
223
|
-
[:table,
|
224
|
-
[:row, 5,
|
225
|
-
[:cell, "what"]],
|
226
|
-
[:row, 6,
|
227
|
-
[:cell, "green"]]]]]]
|
228
|
-
end
|
229
|
-
|
230
|
-
it "should have line numbered steps with inline table" do
|
231
|
-
parse(%{Feature: Hi
|
232
|
-
Scenario Outline: Hello
|
233
|
-
|
234
|
-
Given I have a table
|
235
|
-
|
236
|
-
|<a>|<b>|
|
237
|
-
Examples:
|
238
|
-
|a|b|
|
239
|
-
|c|d|
|
240
|
-
}).to_sexp.should ==
|
241
|
-
[:feature, nil, "Feature: Hi",
|
242
|
-
[:scenario_outline, "Scenario Outline:", "Hello",
|
243
|
-
[:step, 4, "Given", "I have a table",
|
244
|
-
[:table,
|
245
|
-
[:row, 6,
|
246
|
-
[:cell, "<a>"],
|
247
|
-
[:cell, "<b>"]]]],
|
248
|
-
[:examples, "Examples:", "",
|
249
|
-
[:table,
|
250
|
-
[:row, 8,
|
251
|
-
[:cell, "a"],
|
252
|
-
[:cell, "b"]],
|
253
|
-
[:row, 9,
|
254
|
-
[:cell, "c"],
|
255
|
-
[:cell, "d"]]]]]]
|
256
|
-
end
|
257
|
-
|
258
|
-
it "should have examples" do
|
259
|
-
parse("Feature: Hi
|
260
|
-
|
261
|
-
Scenario Outline: Hello
|
262
|
-
|
263
|
-
Given I have a table
|
264
|
-
|1|2|
|
265
|
-
|
266
|
-
Examples:
|
267
|
-
|x|y|
|
268
|
-
|5|6|
|
269
|
-
|
270
|
-
").to_sexp.should ==
|
271
|
-
[:feature, nil, "Feature: Hi",
|
272
|
-
[:scenario_outline, "Scenario Outline:", "Hello",
|
273
|
-
[:step, 5, "Given", "I have a table",
|
274
|
-
[:table,
|
275
|
-
[:row, 6,
|
276
|
-
[:cell, "1"],
|
277
|
-
[:cell, "2"]]]],
|
278
|
-
[:examples, "Examples:", "",
|
279
|
-
[:table,
|
280
|
-
[:row, 9,
|
281
|
-
[:cell, "x"],
|
282
|
-
[:cell, "y"]],
|
283
|
-
[:row, 10,
|
284
|
-
[:cell, "5"],
|
285
|
-
[:cell, "6"]]]]]]
|
286
|
-
end
|
287
|
-
|
288
|
-
it "should allow multiline names" do
|
289
|
-
parse(%{Feature: Hi
|
290
|
-
Scenario Outline: It is my ambition to say
|
291
|
-
in ten sentences
|
292
|
-
what others say
|
293
|
-
in a whole book.
|
294
|
-
Given I am a step
|
295
|
-
|
296
|
-
}).to_sexp.should ==
|
297
|
-
[:feature, nil, "Feature: Hi",
|
298
|
-
[:scenario_outline, "Scenario Outline:", "It is my ambition to say\nin ten sentences\nwhat others say\nin a whole book.",
|
299
|
-
[:step, 6, "Given", "I am a step"]]]
|
300
|
-
end
|
301
|
-
|
302
|
-
it "should allow Examples to have multiline names" do
|
303
|
-
parse(%{Feature: Hi
|
304
|
-
Scenario Outline: name
|
305
|
-
Given I am a step
|
306
|
-
|
307
|
-
Examples: I'm a multiline name
|
308
|
-
and I'm ok
|
309
|
-
|x|
|
310
|
-
|5|
|
311
|
-
|
312
|
-
}).to_sexp.should ==
|
313
|
-
[:feature, nil, "Feature: Hi",
|
314
|
-
[:scenario_outline, "Scenario Outline:", "name",
|
315
|
-
[:step, 3, "Given", "I am a step"],
|
316
|
-
[:examples, "Examples:", "I'm a multiline name\nand I'm ok",
|
317
|
-
[:table,
|
318
|
-
[:row, 7,
|
319
|
-
[:cell, "x"]],
|
320
|
-
[:row, 8,
|
321
|
-
[:cell, "5"]]]]]]
|
322
|
-
end
|
323
|
-
|
324
|
-
it "should allow Examples to have multiline names" do
|
325
|
-
parse(%{Feature: Hi
|
326
|
-
Scenario: When I have when in scenario
|
327
|
-
I should be fine
|
328
|
-
Given I am a step
|
329
|
-
}).to_sexp.should ==
|
330
|
-
[:feature, nil, "Feature: Hi",
|
331
|
-
[:scenario, 2, "Scenario:", "When I have when in scenario\nI should be fine",
|
332
|
-
[:step_invocation, 4, "Given", "I am a step"]]]
|
333
|
-
end
|
334
|
-
end
|
335
|
-
|
336
|
-
describe "Syntax" do
|
337
|
-
it "should parse empty_feature" do
|
338
|
-
parse_file("empty_feature.feature")
|
339
|
-
end
|
340
|
-
|
341
|
-
it "should parse empty_scenario" do
|
342
|
-
parse_file("empty_scenario.feature")
|
343
|
-
end
|
344
|
-
|
345
|
-
it "should parse empty_scenario_outline" do
|
346
|
-
parse_file("empty_scenario_outline.feature")
|
347
|
-
end
|
348
|
-
|
349
|
-
it "should parse fit_scenario" do
|
350
|
-
parse_file("multiline_steps.feature")
|
351
|
-
end
|
352
|
-
|
353
|
-
it "should parse scenario_outline" do
|
354
|
-
parse_file("scenario_outline.feature")
|
355
|
-
end
|
356
|
-
|
357
|
-
it "should parse comments" do
|
358
|
-
parse_file("with_comments.feature")
|
359
|
-
end
|
360
|
-
end
|
361
|
-
|
362
|
-
describe "Filtering" do
|
363
|
-
it "should filter outline tables" do
|
364
|
-
path = '/self_test/features/outline_sample.feature'
|
365
|
-
f = parse_example_file("#{path}:12")
|
366
|
-
actual_sexp = f.to_sexp
|
367
|
-
|
368
|
-
# check path is equivalent, if not same
|
369
|
-
File.expand_path(actual_sexp[1]).should == File.expand_path(File.dirname(__FILE__) + "/../../../examples#{path}")
|
370
|
-
actual_sexp[1] = 'made/up/path.feature'
|
371
|
-
actual_sexp.should ==
|
372
|
-
[:feature,
|
373
|
-
'made/up/path.feature',
|
374
|
-
"Feature: Outline Sample",
|
375
|
-
[:scenario_outline,
|
376
|
-
"Scenario Outline:",
|
377
|
-
"Test state",
|
378
|
-
[:step, 6, "Given", "<state> without a table"],
|
379
|
-
[:step, 7, "Given", "<other_state> without a table"],
|
380
|
-
[:examples,
|
381
|
-
"Examples:",
|
382
|
-
"Rainbow colours",
|
383
|
-
[:table,
|
384
|
-
[:row, 9,
|
385
|
-
[:cell, "state"],
|
386
|
-
[:cell, "other_state"]
|
387
|
-
],
|
388
|
-
[:row, 12,
|
389
|
-
[:cell, "failing"],
|
390
|
-
[:cell, "passing"]
|
391
|
-
]
|
392
|
-
]
|
393
|
-
]
|
394
|
-
]
|
395
|
-
]
|
396
|
-
end
|
397
|
-
end
|
398
|
-
end
|
399
|
-
end
|
400
|
-
end
|