cuke_modeler 1.0.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +12 -0
- data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +5 -5
- data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +8 -5
- data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +8 -5
- data/lib/cuke_modeler/containing.rb +12 -7
- data/lib/cuke_modeler/models/background.rb +7 -2
- data/lib/cuke_modeler/models/cell.rb +2 -1
- data/lib/cuke_modeler/models/doc_string.rb +2 -1
- data/lib/cuke_modeler/models/example.rb +8 -4
- data/lib/cuke_modeler/models/feature.rb +4 -1
- data/lib/cuke_modeler/models/outline.rb +6 -2
- data/lib/cuke_modeler/models/row.rb +2 -1
- data/lib/cuke_modeler/models/scenario.rb +7 -2
- data/lib/cuke_modeler/models/step.rb +2 -1
- data/lib/cuke_modeler/models/table.rb +2 -1
- data/lib/cuke_modeler/models/tag.rb +2 -1
- data/lib/cuke_modeler/parsing.rb +45 -0
- data/lib/cuke_modeler/version.rb +1 -1
- data/testing/cucumber/features/modeling/background_modeling.feature +7 -0
- data/testing/cucumber/features/modeling/background_output.feature +6 -1
- data/testing/cucumber/features/modeling/directory_output.feature +6 -1
- data/testing/cucumber/features/modeling/doc_string_output.feature +6 -1
- data/testing/cucumber/features/modeling/example_modeling.feature +7 -0
- data/testing/cucumber/features/modeling/example_output.feature +6 -1
- data/testing/cucumber/features/modeling/feature_file_output.feature +6 -1
- data/testing/cucumber/features/modeling/feature_modeling.feature +7 -0
- data/testing/cucumber/features/modeling/feature_output.feature +6 -1
- data/testing/cucumber/features/modeling/model_output.feature +1 -8
- data/testing/cucumber/features/modeling/outline_modeling.feature +7 -0
- data/testing/cucumber/features/modeling/outline_output.feature +6 -1
- data/testing/cucumber/features/modeling/row_output.feature +6 -1
- data/testing/cucumber/features/modeling/scenario_modeling.feature +7 -0
- data/testing/cucumber/features/modeling/scenario_output.feature +6 -1
- data/testing/cucumber/features/modeling/step_output.feature +6 -1
- data/testing/cucumber/features/modeling/table_output.feature +6 -1
- data/testing/cucumber/features/modeling/tag_output.feature +6 -1
- data/testing/cucumber/step_definitions/verification_steps.rb +21 -12
- data/testing/dialect_helper.rb +48 -0
- data/testing/rspec/spec/integration/background_integration_spec.rb +93 -88
- data/testing/rspec/spec/integration/cell_integration_spec.rb +26 -27
- data/testing/rspec/spec/integration/directory_integration_spec.rb +4 -4
- data/testing/rspec/spec/integration/doc_string_integration_spec.rb +38 -39
- data/testing/rspec/spec/integration/example_integration_spec.rb +97 -95
- data/testing/rspec/spec/integration/feature_file_integration_spec.rb +5 -5
- data/testing/rspec/spec/integration/feature_integration_spec.rb +157 -155
- data/testing/rspec/spec/integration/gherkin_2_adapter_spec.rb +17 -17
- data/testing/rspec/spec/integration/gherkin_3_adapter_spec.rb +17 -17
- data/testing/rspec/spec/integration/gherkin_4_adapter_spec.rb +17 -17
- data/testing/rspec/spec/integration/outline_integration_spec.rb +359 -354
- data/testing/rspec/spec/integration/parsing_integration_spec.rb +30 -2
- data/testing/rspec/spec/integration/row_integration_spec.rb +23 -25
- data/testing/rspec/spec/integration/scenario_integration_spec.rb +238 -235
- data/testing/rspec/spec/integration/step_integration_spec.rb +69 -64
- data/testing/rspec/spec/integration/table_integration_spec.rb +32 -36
- data/testing/rspec/spec/integration/tag_integration_spec.rb +26 -27
- data/testing/rspec/spec/spec_helper.rb +43 -0
- data/testing/rspec/spec/unit/background_unit_spec.rb +7 -0
- data/testing/rspec/spec/unit/example_unit_spec.rb +7 -0
- data/testing/rspec/spec/unit/feature_unit_spec.rb +7 -0
- data/testing/rspec/spec/unit/outline_unit_spec.rb +7 -0
- data/testing/rspec/spec/unit/parsing_unit_spec.rb +33 -0
- data/testing/rspec/spec/unit/scenario_unit_spec.rb +7 -0
- data/testing/rspec/spec/unit/shared/keyworded_models_unit_specs.rb +58 -0
- data/testing/rspec/spec/unit/step_unit_spec.rb +1 -23
- data/testing/test_languages.json +45 -0
- data/todo.txt +1 -1
- metadata +6 -3
@@ -49,7 +49,7 @@ describe 'Directory, Integration' do
|
|
49
49
|
feature_files.each do |file_name|
|
50
50
|
# Some versions of Gherkin require feature content to be present in feature files
|
51
51
|
File.open("#{directory_path}/#{file_name}", "w") { |file|
|
52
|
-
file.puts(
|
52
|
+
file.puts("#{@feature_keyword}: Test feature")
|
53
53
|
}
|
54
54
|
end
|
55
55
|
|
@@ -79,7 +79,7 @@ describe 'Directory, Integration' do
|
|
79
79
|
context 'with no feature files' do
|
80
80
|
|
81
81
|
before(:each) do
|
82
|
-
FileUtils.rm(Dir.glob("#{directory_path}
|
82
|
+
FileUtils.rm(Dir.glob("#{directory_path}/#{@step_keyword}"))
|
83
83
|
end
|
84
84
|
|
85
85
|
|
@@ -114,7 +114,7 @@ describe 'Directory, Integration' do
|
|
114
114
|
context 'with no directories' do
|
115
115
|
|
116
116
|
before(:each) do
|
117
|
-
FileUtils.rm_r(Dir.glob("#{directory_path}
|
117
|
+
FileUtils.rm_r(Dir.glob("#{directory_path}/#{@step_keyword}"))
|
118
118
|
end
|
119
119
|
|
120
120
|
|
@@ -153,7 +153,7 @@ describe 'Directory, Integration' do
|
|
153
153
|
|
154
154
|
FileUtils.mkdir(nested_directory)
|
155
155
|
File.open(file_path, "w") { |file|
|
156
|
-
file.puts(
|
156
|
+
file.puts("#{@feature_keyword}: Test feature")
|
157
157
|
}
|
158
158
|
|
159
159
|
directory = clazz.new(@default_file_directory)
|
@@ -63,16 +63,15 @@ describe 'DocString, Integration' do
|
|
63
63
|
describe 'getting ancestors' do
|
64
64
|
|
65
65
|
before(:each) do
|
66
|
-
source =
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
source = source.join("\n")
|
66
|
+
source = "#{@feature_keyword}: Test feature
|
67
|
+
|
68
|
+
#{@scenario_keyword}: Test test
|
69
|
+
#{@step_keyword} a big step:
|
70
|
+
\"\"\"
|
71
|
+
a
|
72
|
+
doc
|
73
|
+
string
|
74
|
+
\"\"\""
|
76
75
|
|
77
76
|
file_path = "#{@default_file_directory}/doc_string_test_file.feature"
|
78
77
|
File.open(file_path, 'w') { |file| file.write(source) }
|
@@ -103,15 +102,15 @@ describe 'DocString, Integration' do
|
|
103
102
|
context 'a doc string that is part of a scenario' do
|
104
103
|
|
105
104
|
before(:each) do
|
106
|
-
source =
|
105
|
+
source = "#{@feature_keyword}: Test feature
|
107
106
|
|
108
|
-
|
109
|
-
|
110
|
-
"""
|
107
|
+
#{@scenario_keyword}: Test test
|
108
|
+
#{@step_keyword} a big step:
|
109
|
+
\"\"\"
|
111
110
|
a
|
112
111
|
doc
|
113
112
|
string
|
114
|
-
"""
|
113
|
+
\"\"\""
|
115
114
|
|
116
115
|
file_path = "#{@default_file_directory}/doc_string_test_file.feature"
|
117
116
|
File.open(file_path, 'w') { |file| file.write(source) }
|
@@ -132,18 +131,18 @@ describe 'DocString, Integration' do
|
|
132
131
|
context 'a doc string that is part of an outline' do
|
133
132
|
|
134
133
|
before(:each) do
|
135
|
-
source =
|
134
|
+
source = "#{@feature_keyword}: Test feature
|
136
135
|
|
137
|
-
|
138
|
-
|
139
|
-
"""
|
136
|
+
#{@outline_keyword}: Test outline
|
137
|
+
#{@step_keyword} a big step:
|
138
|
+
\"\"\"
|
140
139
|
a
|
141
140
|
doc
|
142
141
|
string
|
143
|
-
"""
|
144
|
-
|
142
|
+
\"\"\"
|
143
|
+
#{@example_keyword}:
|
145
144
|
| param |
|
146
|
-
| value |
|
145
|
+
| value |"
|
147
146
|
|
148
147
|
file_path = "#{@default_file_directory}/doc_string_test_file.feature"
|
149
148
|
File.open(file_path, 'w') { |file| file.write(source) }
|
@@ -164,15 +163,15 @@ describe 'DocString, Integration' do
|
|
164
163
|
context 'a doc string that is part of a background' do
|
165
164
|
|
166
165
|
before(:each) do
|
167
|
-
source =
|
166
|
+
source = "#{@feature_keyword}: Test feature
|
168
167
|
|
169
|
-
|
170
|
-
|
171
|
-
"""
|
168
|
+
#{@background_keyword}: Test background
|
169
|
+
#{@step_keyword} a big step:
|
170
|
+
\"\"\"
|
172
171
|
a
|
173
172
|
doc
|
174
173
|
string
|
175
|
-
"""
|
174
|
+
\"\"\""
|
176
175
|
|
177
176
|
file_path = "#{@default_file_directory}/doc_string_test_file.feature"
|
178
177
|
File.open(file_path, 'w') { |file| file.write(source) }
|
@@ -244,13 +243,13 @@ describe 'DocString, Integration' do
|
|
244
243
|
end
|
245
244
|
|
246
245
|
it "models the doc string's source line" do
|
247
|
-
source_text =
|
246
|
+
source_text = "#{@feature_keyword}:
|
248
247
|
|
249
|
-
|
250
|
-
|
251
|
-
"""
|
248
|
+
#{@scenario_keyword}:
|
249
|
+
#{@step_keyword} step
|
250
|
+
\"\"\"
|
252
251
|
foo
|
253
|
-
"""
|
252
|
+
\"\"\""
|
254
253
|
doc_string = CukeModeler::Feature.new(source_text).tests.first.steps.first.block
|
255
254
|
|
256
255
|
expect(doc_string.source_line).to eq(5)
|
@@ -265,7 +264,7 @@ describe 'DocString, Integration' do
|
|
265
264
|
|
266
265
|
it 'can be remade from its own output' do
|
267
266
|
source = ['"""" the type',
|
268
|
-
|
267
|
+
"#{@step_keyword} a step",
|
269
268
|
' \"\"\"',
|
270
269
|
' that also has a doc string',
|
271
270
|
' \"\"\"',
|
@@ -288,7 +287,7 @@ describe 'DocString, Integration' do
|
|
288
287
|
source = source.join("\n")
|
289
288
|
doc_string = clazz.new(source)
|
290
289
|
|
291
|
-
doc_string_output = doc_string.to_s.split("\n")
|
290
|
+
doc_string_output = doc_string.to_s.split("\n", -1)
|
292
291
|
|
293
292
|
expect(doc_string_output).to eq(['"""', '"""'])
|
294
293
|
end
|
@@ -299,7 +298,7 @@ describe 'DocString, Integration' do
|
|
299
298
|
source = source.join("\n")
|
300
299
|
doc_string = clazz.new(source)
|
301
300
|
|
302
|
-
doc_string_output = doc_string.to_s.split("\n")
|
301
|
+
doc_string_output = doc_string.to_s.split("\n", -1)
|
303
302
|
|
304
303
|
expect(doc_string_output).to eq(['""" foo',
|
305
304
|
'"""'])
|
@@ -312,7 +311,7 @@ describe 'DocString, Integration' do
|
|
312
311
|
source = source.join("\n")
|
313
312
|
doc_string = clazz.new(source)
|
314
313
|
|
315
|
-
doc_string_output = doc_string.to_s.split("\n")
|
314
|
+
doc_string_output = doc_string.to_s.split("\n", -1)
|
316
315
|
|
317
316
|
expect(doc_string_output).to eq(['"""',
|
318
317
|
'foo',
|
@@ -332,7 +331,7 @@ describe 'DocString, Integration' do
|
|
332
331
|
source = source.join("\n")
|
333
332
|
doc_string = clazz.new(source)
|
334
333
|
|
335
|
-
doc_string_output = doc_string.to_s.split("\n")
|
334
|
+
doc_string_output = doc_string.to_s.split("\n", -1)
|
336
335
|
|
337
336
|
expect(doc_string_output).to eq(['"""',
|
338
337
|
'a \"\"\"',
|
@@ -350,7 +349,7 @@ describe 'DocString, Integration' do
|
|
350
349
|
source = source.join("\n")
|
351
350
|
doc_string = clazz.new(source)
|
352
351
|
|
353
|
-
doc_string_output = doc_string.to_s.split("\n")
|
352
|
+
doc_string_output = doc_string.to_s.split("\n", -1)
|
354
353
|
|
355
354
|
expect(doc_string_output).to eq(['"""',
|
356
355
|
'change these \"\"\"\"\"\"',
|
@@ -367,7 +366,7 @@ describe 'DocString, Integration' do
|
|
367
366
|
source = source.join("\n")
|
368
367
|
doc_string = clazz.new(source)
|
369
368
|
|
370
|
-
doc_string_output = doc_string.to_s.split("\n")
|
369
|
+
doc_string_output = doc_string.to_s.split("\n", -1)
|
371
370
|
|
372
371
|
expect(doc_string_output).to eq(['""" type foo',
|
373
372
|
'\"\"\"',
|
@@ -16,31 +16,28 @@ describe 'Example, Integration' do
|
|
16
16
|
describe 'unique behavior' do
|
17
17
|
|
18
18
|
it 'can be instantiated with the minimum viable Gherkin', :gherkin4 => true do
|
19
|
-
source =
|
20
|
-
source = source.join("\n")
|
19
|
+
source = "#{@example_keyword}:"
|
21
20
|
|
22
21
|
expect { @model = clazz.new(source) }.to_not raise_error
|
23
22
|
end
|
24
23
|
|
25
24
|
it 'can be instantiated with the minimum viable Gherkin', :gherkin3 => true do
|
26
|
-
source =
|
27
|
-
|
28
|
-
|
29
|
-
source = source.join("\n")
|
25
|
+
source = "#{@example_keyword}:
|
26
|
+
|param|
|
27
|
+
|value|"
|
30
28
|
|
31
29
|
expect { @model = clazz.new(source) }.to_not raise_error
|
32
30
|
end
|
33
31
|
|
34
32
|
it 'can be instantiated with the minimum viable Gherkin', :gherkin2 => true do
|
35
|
-
source =
|
36
|
-
|
37
|
-
source = source.join("\n")
|
33
|
+
source = "#{@example_keyword}:
|
34
|
+
|param|"
|
38
35
|
|
39
36
|
expect { @model = clazz.new(source) }.to_not raise_error
|
40
37
|
end
|
41
38
|
|
42
39
|
it 'stores the original data generated by the parsing adapter', :gherkin4 => true do
|
43
|
-
example = clazz.new("@tag\
|
40
|
+
example = clazz.new("@tag\n#{@example_keyword}: test example\ndescription\n|param|\n|value|")
|
44
41
|
data = example.parsing_data
|
45
42
|
|
46
43
|
expect(data.keys).to match_array([:type, :tags, :location, :keyword, :name, :tableHeader, :tableBody, :description])
|
@@ -48,7 +45,7 @@ describe 'Example, Integration' do
|
|
48
45
|
end
|
49
46
|
|
50
47
|
it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
|
51
|
-
example = clazz.new("@tag\
|
48
|
+
example = clazz.new("@tag\n#{@example_keyword}: test example\ndescription\n|param|\n|value|")
|
52
49
|
data = example.parsing_data
|
53
50
|
|
54
51
|
expect(data.keys).to match_array([:type, :tags, :location, :keyword, :name, :tableHeader, :tableBody, :description])
|
@@ -56,7 +53,7 @@ describe 'Example, Integration' do
|
|
56
53
|
end
|
57
54
|
|
58
55
|
it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
|
59
|
-
example = clazz.new("@tag\
|
56
|
+
example = clazz.new("@tag\n#{@example_keyword}: test example\ndescription\n|param|\n|value|")
|
60
57
|
data = example.parsing_data
|
61
58
|
|
62
59
|
expect(data.keys).to match_array(['keyword', 'name', 'line', 'description', 'id', 'rows', 'tags'])
|
@@ -70,7 +67,7 @@ describe 'Example, Integration' do
|
|
70
67
|
end
|
71
68
|
|
72
69
|
it 'trims whitespace from its source description' do
|
73
|
-
source = [
|
70
|
+
source = ["#{@example_keyword}:",
|
74
71
|
' ',
|
75
72
|
' description line 1',
|
76
73
|
'',
|
@@ -84,7 +81,7 @@ describe 'Example, Integration' do
|
|
84
81
|
source = source.join("\n")
|
85
82
|
|
86
83
|
example = clazz.new(source)
|
87
|
-
description = example.description.split("\n")
|
84
|
+
description = example.description.split("\n", -1)
|
88
85
|
|
89
86
|
expect(description).to eq([' description line 1',
|
90
87
|
'',
|
@@ -97,12 +94,21 @@ describe 'Example, Integration' do
|
|
97
94
|
|
98
95
|
context 'from source text' do
|
99
96
|
|
97
|
+
let(:source_text) { "#{@example_keyword}:" }
|
98
|
+
let(:example) { clazz.new(source_text) }
|
99
|
+
|
100
|
+
|
101
|
+
# gherkin 2.x/3.x does not accept incomplete examples
|
102
|
+
it "models the example's keyword", :gherkin2 => false, :gherkin3 => false do
|
103
|
+
expect(example.keyword).to eq("#{@example_keyword}")
|
104
|
+
end
|
105
|
+
|
100
106
|
it "models the example's source line" do
|
101
|
-
source_text = "
|
107
|
+
source_text = "#{@feature_keyword}:
|
102
108
|
|
103
|
-
|
104
|
-
|
105
|
-
|
109
|
+
#{@outline_keyword}:
|
110
|
+
#{@step_keyword} step
|
111
|
+
#{@example_keyword}:
|
106
112
|
| param |
|
107
113
|
| value |"
|
108
114
|
example = CukeModeler::Feature.new(source_text).tests.first.examples.first
|
@@ -114,7 +120,7 @@ describe 'Example, Integration' do
|
|
114
120
|
context 'a filled example' do
|
115
121
|
|
116
122
|
let(:source_text) { "@tag1 @tag2 @tag3
|
117
|
-
|
123
|
+
#{@example_keyword}: test example
|
118
124
|
|
119
125
|
Some example description.
|
120
126
|
|
@@ -131,7 +137,7 @@ describe 'Example, Integration' do
|
|
131
137
|
end
|
132
138
|
|
133
139
|
it "models the example's description" do
|
134
|
-
description = example.description.split("\n")
|
140
|
+
description = example.description.split("\n", -1)
|
135
141
|
|
136
142
|
expect(description).to eq([' Some example description.',
|
137
143
|
'',
|
@@ -160,7 +166,7 @@ describe 'Example, Integration' do
|
|
160
166
|
# gherkin 2.x/3.x does not accept incomplete examples
|
161
167
|
context 'an empty example', :gherkin2 => false, :gherkin3 => false do
|
162
168
|
|
163
|
-
let(:source_text) {
|
169
|
+
let(:source_text) { "#{@example_keyword}:" }
|
164
170
|
let(:example) { clazz.new(source_text) }
|
165
171
|
|
166
172
|
|
@@ -188,11 +194,10 @@ describe 'Example, Integration' do
|
|
188
194
|
|
189
195
|
|
190
196
|
it 'properly sets its child models' do
|
191
|
-
source =
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
source = source.join("\n")
|
197
|
+
source = "@a_tag
|
198
|
+
#{@example_keyword}:
|
199
|
+
| param |
|
200
|
+
| value 1 |"
|
196
201
|
|
197
202
|
example = clazz.new(source)
|
198
203
|
rows = example.rows
|
@@ -204,7 +209,7 @@ describe 'Example, Integration' do
|
|
204
209
|
end
|
205
210
|
|
206
211
|
it 'does not include the parameter row when accessing argument rows' do
|
207
|
-
source = "
|
212
|
+
source = "#{@example_keyword}:\n|param1|param2|\n|value1|value2|\n|value3|value4|"
|
208
213
|
example = clazz.new(source)
|
209
214
|
|
210
215
|
rows = example.argument_rows
|
@@ -214,7 +219,7 @@ describe 'Example, Integration' do
|
|
214
219
|
end
|
215
220
|
|
216
221
|
it 'does not include argument rows when accessing the parameter row' do
|
217
|
-
source = "
|
222
|
+
source = "#{@example_keyword}:\n|param1|param2|\n|value1|value2|\n|value3|value4|"
|
218
223
|
example = clazz.new(source)
|
219
224
|
|
220
225
|
row = example.parameter_row
|
@@ -227,7 +232,7 @@ describe 'Example, Integration' do
|
|
227
232
|
describe 'adding rows' do
|
228
233
|
|
229
234
|
it 'can add a new row as a hash, string values' do
|
230
|
-
source = "
|
235
|
+
source = "#{@example_keyword}:\n|param1|param2|\n|value1|value2|"
|
231
236
|
example = clazz.new(source)
|
232
237
|
|
233
238
|
new_row = {'param1' => 'value3', 'param2' => 'value4'}
|
@@ -238,7 +243,7 @@ describe 'Example, Integration' do
|
|
238
243
|
end
|
239
244
|
|
240
245
|
it 'can add a new row as a hash, non-string values' do
|
241
|
-
source = "
|
246
|
+
source = "#{@example_keyword}:\n|param1|param2|\n|value1|value2|"
|
242
247
|
example = clazz.new(source)
|
243
248
|
|
244
249
|
new_row = {:param1 => 'value3', 'param2' => 4}
|
@@ -249,7 +254,7 @@ describe 'Example, Integration' do
|
|
249
254
|
end
|
250
255
|
|
251
256
|
it 'can add a new row as a hash, random key order' do
|
252
|
-
source = "
|
257
|
+
source = "#{@example_keyword}:\n|param1|param2|\n|value1|value2|"
|
253
258
|
example = clazz.new(source)
|
254
259
|
|
255
260
|
new_row = {'param2' => 'value4', 'param1' => 'value3'}
|
@@ -260,7 +265,7 @@ describe 'Example, Integration' do
|
|
260
265
|
end
|
261
266
|
|
262
267
|
it 'can add a new row as an array, string values' do
|
263
|
-
source = "
|
268
|
+
source = "#{@example_keyword}:\n|param1|param2|\n|value1|value2|"
|
264
269
|
example = clazz.new(source)
|
265
270
|
|
266
271
|
new_row = ['value3', 'value4']
|
@@ -271,7 +276,7 @@ describe 'Example, Integration' do
|
|
271
276
|
end
|
272
277
|
|
273
278
|
it 'can add a new row as an array, non-string values' do
|
274
|
-
source = "
|
279
|
+
source = "#{@example_keyword}:\n|param1|param2|param3|\n|value1|value2|value3|"
|
275
280
|
example = clazz.new(source)
|
276
281
|
|
277
282
|
new_row = [:value4, 5, 'value6']
|
@@ -282,7 +287,7 @@ describe 'Example, Integration' do
|
|
282
287
|
end
|
283
288
|
|
284
289
|
it 'can only use a Hash or an Array to add a new row' do
|
285
|
-
source = "
|
290
|
+
source = "#{@example_keyword}:\n|param|\n|value|"
|
286
291
|
example = clazz.new(source)
|
287
292
|
|
288
293
|
expect { example.add_row({}) }.to_not raise_error
|
@@ -291,7 +296,7 @@ describe 'Example, Integration' do
|
|
291
296
|
end
|
292
297
|
|
293
298
|
it 'trims whitespace from added rows' do
|
294
|
-
source = "
|
299
|
+
source = "#{@example_keyword}:\n|param1|param2|\n|value1|value2|"
|
295
300
|
example = clazz.new(source)
|
296
301
|
|
297
302
|
hash_row = {'param1' => 'value3 ', 'param2' => ' value4'}
|
@@ -315,7 +320,7 @@ describe 'Example, Integration' do
|
|
315
320
|
end
|
316
321
|
|
317
322
|
it 'does not modify its row input' do
|
318
|
-
source = "
|
323
|
+
source = "#{@example_keyword}:\n|param1|param2|\n|value1|value2|"
|
319
324
|
example = clazz.new(source)
|
320
325
|
|
321
326
|
array_row = ['value1'.freeze, 'value2'.freeze].freeze
|
@@ -331,7 +336,7 @@ describe 'Example, Integration' do
|
|
331
336
|
describe 'removing rows' do
|
332
337
|
|
333
338
|
it 'can remove an existing row as a hash' do
|
334
|
-
source = "
|
339
|
+
source = "#{@example_keyword}:\n|param1|param2|\n|value1|value2|\n|value3|value4|"
|
335
340
|
example = clazz.new(source)
|
336
341
|
|
337
342
|
old_row = {'param1' => 'value3', 'param2' => 'value4'}
|
@@ -342,7 +347,7 @@ describe 'Example, Integration' do
|
|
342
347
|
end
|
343
348
|
|
344
349
|
it 'can remove an existing row as a hash, random key order' do
|
345
|
-
source = "
|
350
|
+
source = "#{@example_keyword}:\n|param1|param2|\n|value1|value2|\n|value3|value4|"
|
346
351
|
example = clazz.new(source)
|
347
352
|
|
348
353
|
old_row = {'param2' => 'value4', 'param1' => 'value3'}
|
@@ -353,7 +358,7 @@ describe 'Example, Integration' do
|
|
353
358
|
end
|
354
359
|
|
355
360
|
it 'can remove an existing row as an array' do
|
356
|
-
source = "
|
361
|
+
source = "#{@example_keyword}:\n|param1|param2|\n|value1|value2|\n|value3|value4|"
|
357
362
|
example = clazz.new(source)
|
358
363
|
|
359
364
|
old_row = ['value3', 'value4']
|
@@ -370,7 +375,7 @@ describe 'Example, Integration' do
|
|
370
375
|
end
|
371
376
|
|
372
377
|
it 'trims whitespace from removed rows' do
|
373
|
-
source = "
|
378
|
+
source = "#{@example_keyword}:\n|param1|param2|\n|value1|value2|\n|value3|value4|\n|value5|value6|"
|
374
379
|
example = clazz.new(source)
|
375
380
|
|
376
381
|
# These will affect different rows
|
@@ -393,7 +398,7 @@ describe 'Example, Integration' do
|
|
393
398
|
end
|
394
399
|
|
395
400
|
it 'will not remove the parameter row' do
|
396
|
-
source = "
|
401
|
+
source = "#{@example_keyword}:\n|param1|param2|\n|value1|value2|"
|
397
402
|
example = clazz.new(source)
|
398
403
|
|
399
404
|
hash_row = {'param1' => 'param1 ', 'param2' => ' param2'}
|
@@ -416,14 +421,13 @@ describe 'Example, Integration' do
|
|
416
421
|
describe 'getting ancestors' do
|
417
422
|
|
418
423
|
before(:each) do
|
419
|
-
source =
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
source = source.join("\n")
|
424
|
+
source = "#{@feature_keyword}: Test feature
|
425
|
+
|
426
|
+
#{@outline_keyword}: Test test
|
427
|
+
#{@step_keyword} a step
|
428
|
+
#{@example_keyword}: Test example
|
429
|
+
| a param |
|
430
|
+
| a value |"
|
427
431
|
|
428
432
|
file_path = "#{@default_file_directory}/example_test_file.feature"
|
429
433
|
File.open(file_path, 'w') { |file| file.write(source) }
|
@@ -454,13 +458,13 @@ describe 'Example, Integration' do
|
|
454
458
|
context 'an example that is part of an outline' do
|
455
459
|
|
456
460
|
before(:each) do
|
457
|
-
source =
|
461
|
+
source = "#{@feature_keyword}: Test feature
|
458
462
|
|
459
|
-
|
460
|
-
|
461
|
-
|
463
|
+
#{@outline_keyword}: Test outline
|
464
|
+
#{@step_keyword} a step
|
465
|
+
#{@example_keyword}:
|
462
466
|
| param |
|
463
|
-
| value |
|
467
|
+
| value |"
|
464
468
|
|
465
469
|
file_path = "#{@default_file_directory}/example_test_file.feature"
|
466
470
|
File.open(file_path, 'w') { |file| file.write(source) }
|
@@ -490,16 +494,15 @@ describe 'Example, Integration' do
|
|
490
494
|
describe 'example output' do
|
491
495
|
|
492
496
|
it 'can be remade from its own output' do
|
493
|
-
source =
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
source = source.join("\n")
|
497
|
+
source = "@tag1 @tag2 @tag3
|
498
|
+
#{@example_keyword}: with everything it could have
|
499
|
+
|
500
|
+
Some description.
|
501
|
+
Some more description.
|
502
|
+
|
503
|
+
| param1 | param2 |
|
504
|
+
| value1 | value2 |
|
505
|
+
| value3 | value4 |"
|
503
506
|
example = clazz.new(source)
|
504
507
|
|
505
508
|
example_output = example.to_s
|
@@ -514,16 +517,16 @@ describe 'Example, Integration' do
|
|
514
517
|
# and it is possible that during that process it messes up the cell's output.
|
515
518
|
|
516
519
|
it 'can correctly output a row that has special characters in it' do
|
517
|
-
source = [
|
520
|
+
source = ["#{@example_keyword}:",
|
518
521
|
' | param with \| |',
|
519
522
|
' | a value with \| and \\\\ |',
|
520
523
|
' | a value with \\\\ |']
|
521
524
|
source = source.join("\n")
|
522
525
|
example = clazz.new(source)
|
523
526
|
|
524
|
-
example_output = example.to_s.split("\n")
|
527
|
+
example_output = example.to_s.split("\n", -1)
|
525
528
|
|
526
|
-
expect(example_output).to eq([
|
529
|
+
expect(example_output).to eq(["#{@example_keyword}:",
|
527
530
|
' | param with \| |',
|
528
531
|
' | a value with \| and \\\\ |',
|
529
532
|
' | a value with \\\\ |'])
|
@@ -534,37 +537,37 @@ describe 'Example, Integration' do
|
|
534
537
|
|
535
538
|
# gherkin 2.x/3.x does not accept incomplete examples
|
536
539
|
it 'can output an empty example', :gherkin2 => false, :gherkin3 => false do
|
537
|
-
source = [
|
540
|
+
source = ["#{@example_keyword}:"]
|
538
541
|
source = source.join("\n")
|
539
542
|
example = clazz.new(source)
|
540
543
|
|
541
|
-
example_output = example.to_s.split("\n")
|
544
|
+
example_output = example.to_s.split("\n", -1)
|
542
545
|
|
543
|
-
expect(example_output).to eq([
|
546
|
+
expect(example_output).to eq(["#{@example_keyword}:"])
|
544
547
|
end
|
545
548
|
|
546
549
|
# gherkin 2.x/3.x does not accept incomplete examples
|
547
550
|
it 'can output an example that has a name', :gherkin2 => false, :gherkin3 => false do
|
548
|
-
source = [
|
551
|
+
source = ["#{@example_keyword}: test example"]
|
549
552
|
source = source.join("\n")
|
550
553
|
example = clazz.new(source)
|
551
554
|
|
552
|
-
example_output = example.to_s.split("\n")
|
555
|
+
example_output = example.to_s.split("\n", -1)
|
553
556
|
|
554
|
-
expect(example_output).to eq([
|
557
|
+
expect(example_output).to eq(["#{@example_keyword}: test example"])
|
555
558
|
end
|
556
559
|
|
557
560
|
# gherkin 2.x/3.x does not accept incomplete examples
|
558
561
|
it 'can output an example that has a description', :gherkin2 => false, :gherkin3 => false do
|
559
|
-
source = [
|
562
|
+
source = ["#{@example_keyword}:",
|
560
563
|
'Some description.',
|
561
564
|
'Some more description.']
|
562
565
|
source = source.join("\n")
|
563
566
|
example = clazz.new(source)
|
564
567
|
|
565
|
-
example_output = example.to_s.split("\n")
|
568
|
+
example_output = example.to_s.split("\n", -1)
|
566
569
|
|
567
|
-
expect(example_output).to eq([
|
570
|
+
expect(example_output).to eq(["#{@example_keyword}:",
|
568
571
|
'',
|
569
572
|
'Some description.',
|
570
573
|
'Some more description.'])
|
@@ -573,28 +576,28 @@ describe 'Example, Integration' do
|
|
573
576
|
|
574
577
|
# gherkin 3.x does not accept incomplete examples
|
575
578
|
it 'can output an example that has a single row', :gherkin3 => false do
|
576
|
-
source = [
|
579
|
+
source = ["#{@example_keyword}:",
|
577
580
|
'|param1|param2|']
|
578
581
|
source = source.join("\n")
|
579
582
|
example = clazz.new(source)
|
580
583
|
|
581
|
-
example_output = example.to_s.split("\n")
|
584
|
+
example_output = example.to_s.split("\n", -1)
|
582
585
|
|
583
|
-
expect(example_output).to eq([
|
586
|
+
expect(example_output).to eq(["#{@example_keyword}:",
|
584
587
|
' | param1 | param2 |'])
|
585
588
|
end
|
586
589
|
|
587
590
|
it 'can output an example that has multiple rows' do
|
588
|
-
source = [
|
591
|
+
source = ["#{@example_keyword}:",
|
589
592
|
'|param1|param2|',
|
590
593
|
'|value1|value2|',
|
591
594
|
'|value3|value4|']
|
592
595
|
source = source.join("\n")
|
593
596
|
example = clazz.new(source)
|
594
597
|
|
595
|
-
example_output = example.to_s.split("\n")
|
598
|
+
example_output = example.to_s.split("\n", -1)
|
596
599
|
|
597
|
-
expect(example_output).to eq([
|
600
|
+
expect(example_output).to eq(["#{@example_keyword}:",
|
598
601
|
' | param1 | param2 |',
|
599
602
|
' | value1 | value2 |',
|
600
603
|
' | value3 | value4 |'])
|
@@ -603,17 +606,17 @@ describe 'Example, Integration' do
|
|
603
606
|
it 'can output an example that has tags' do
|
604
607
|
source = ['@tag1',
|
605
608
|
'@tag2 @tag3',
|
606
|
-
|
609
|
+
"#{@example_keyword}:",
|
607
610
|
'|param1|param2|',
|
608
611
|
'|value1|value2|',
|
609
612
|
'|value3|value4|']
|
610
613
|
source = source.join("\n")
|
611
614
|
example = clazz.new(source)
|
612
615
|
|
613
|
-
example_output = example.to_s.split("\n")
|
616
|
+
example_output = example.to_s.split("\n", -1)
|
614
617
|
|
615
618
|
expect(example_output).to eq(['@tag1 @tag2 @tag3',
|
616
|
-
|
619
|
+
"#{@example_keyword}:",
|
617
620
|
' | param1 | param2 |',
|
618
621
|
' | value1 | value2 |',
|
619
622
|
' | value3 | value4 |'])
|
@@ -622,7 +625,7 @@ describe 'Example, Integration' do
|
|
622
625
|
it 'can output an example that has everything' do
|
623
626
|
source = ['@tag1',
|
624
627
|
'@tag2 @tag3',
|
625
|
-
|
628
|
+
"#{@example_keyword}: with everything it could have",
|
626
629
|
'Some description.',
|
627
630
|
'Some more description.',
|
628
631
|
'|param1|param2|',
|
@@ -631,10 +634,10 @@ describe 'Example, Integration' do
|
|
631
634
|
source = source.join("\n")
|
632
635
|
example = clazz.new(source)
|
633
636
|
|
634
|
-
example_output = example.to_s.split("\n")
|
637
|
+
example_output = example.to_s.split("\n", -1)
|
635
638
|
|
636
639
|
expect(example_output).to eq(['@tag1 @tag2 @tag3',
|
637
|
-
|
640
|
+
"#{@example_keyword}: with everything it could have",
|
638
641
|
'',
|
639
642
|
'Some description.',
|
640
643
|
'Some more description.',
|
@@ -645,16 +648,15 @@ describe 'Example, Integration' do
|
|
645
648
|
end
|
646
649
|
|
647
650
|
it 'buffers row cells based on the longest value in a column' do
|
648
|
-
source =
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
source = source.join("\n")
|
651
|
+
source = "#{@example_keyword}:
|
652
|
+
|parameter 1| x|
|
653
|
+
|y|value 1|
|
654
|
+
|a|b|"
|
653
655
|
example = clazz.new(source)
|
654
656
|
|
655
|
-
example_output = example.to_s.split("\n")
|
657
|
+
example_output = example.to_s.split("\n", -1)
|
656
658
|
|
657
|
-
expect(example_output).to eq([
|
659
|
+
expect(example_output).to eq(["#{@example_keyword}:",
|
658
660
|
' | parameter 1 | x |',
|
659
661
|
' | y | value 1 |',
|
660
662
|
' | a | b |'])
|