cuke_modeler 1.0.4 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +12 -0
  3. data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +5 -5
  4. data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +8 -5
  5. data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +8 -5
  6. data/lib/cuke_modeler/containing.rb +12 -7
  7. data/lib/cuke_modeler/models/background.rb +7 -2
  8. data/lib/cuke_modeler/models/cell.rb +2 -1
  9. data/lib/cuke_modeler/models/doc_string.rb +2 -1
  10. data/lib/cuke_modeler/models/example.rb +8 -4
  11. data/lib/cuke_modeler/models/feature.rb +4 -1
  12. data/lib/cuke_modeler/models/outline.rb +6 -2
  13. data/lib/cuke_modeler/models/row.rb +2 -1
  14. data/lib/cuke_modeler/models/scenario.rb +7 -2
  15. data/lib/cuke_modeler/models/step.rb +2 -1
  16. data/lib/cuke_modeler/models/table.rb +2 -1
  17. data/lib/cuke_modeler/models/tag.rb +2 -1
  18. data/lib/cuke_modeler/parsing.rb +45 -0
  19. data/lib/cuke_modeler/version.rb +1 -1
  20. data/testing/cucumber/features/modeling/background_modeling.feature +7 -0
  21. data/testing/cucumber/features/modeling/background_output.feature +6 -1
  22. data/testing/cucumber/features/modeling/directory_output.feature +6 -1
  23. data/testing/cucumber/features/modeling/doc_string_output.feature +6 -1
  24. data/testing/cucumber/features/modeling/example_modeling.feature +7 -0
  25. data/testing/cucumber/features/modeling/example_output.feature +6 -1
  26. data/testing/cucumber/features/modeling/feature_file_output.feature +6 -1
  27. data/testing/cucumber/features/modeling/feature_modeling.feature +7 -0
  28. data/testing/cucumber/features/modeling/feature_output.feature +6 -1
  29. data/testing/cucumber/features/modeling/model_output.feature +1 -8
  30. data/testing/cucumber/features/modeling/outline_modeling.feature +7 -0
  31. data/testing/cucumber/features/modeling/outline_output.feature +6 -1
  32. data/testing/cucumber/features/modeling/row_output.feature +6 -1
  33. data/testing/cucumber/features/modeling/scenario_modeling.feature +7 -0
  34. data/testing/cucumber/features/modeling/scenario_output.feature +6 -1
  35. data/testing/cucumber/features/modeling/step_output.feature +6 -1
  36. data/testing/cucumber/features/modeling/table_output.feature +6 -1
  37. data/testing/cucumber/features/modeling/tag_output.feature +6 -1
  38. data/testing/cucumber/step_definitions/verification_steps.rb +21 -12
  39. data/testing/dialect_helper.rb +48 -0
  40. data/testing/rspec/spec/integration/background_integration_spec.rb +93 -88
  41. data/testing/rspec/spec/integration/cell_integration_spec.rb +26 -27
  42. data/testing/rspec/spec/integration/directory_integration_spec.rb +4 -4
  43. data/testing/rspec/spec/integration/doc_string_integration_spec.rb +38 -39
  44. data/testing/rspec/spec/integration/example_integration_spec.rb +97 -95
  45. data/testing/rspec/spec/integration/feature_file_integration_spec.rb +5 -5
  46. data/testing/rspec/spec/integration/feature_integration_spec.rb +157 -155
  47. data/testing/rspec/spec/integration/gherkin_2_adapter_spec.rb +17 -17
  48. data/testing/rspec/spec/integration/gherkin_3_adapter_spec.rb +17 -17
  49. data/testing/rspec/spec/integration/gherkin_4_adapter_spec.rb +17 -17
  50. data/testing/rspec/spec/integration/outline_integration_spec.rb +359 -354
  51. data/testing/rspec/spec/integration/parsing_integration_spec.rb +30 -2
  52. data/testing/rspec/spec/integration/row_integration_spec.rb +23 -25
  53. data/testing/rspec/spec/integration/scenario_integration_spec.rb +238 -235
  54. data/testing/rspec/spec/integration/step_integration_spec.rb +69 -64
  55. data/testing/rspec/spec/integration/table_integration_spec.rb +32 -36
  56. data/testing/rspec/spec/integration/tag_integration_spec.rb +26 -27
  57. data/testing/rspec/spec/spec_helper.rb +43 -0
  58. data/testing/rspec/spec/unit/background_unit_spec.rb +7 -0
  59. data/testing/rspec/spec/unit/example_unit_spec.rb +7 -0
  60. data/testing/rspec/spec/unit/feature_unit_spec.rb +7 -0
  61. data/testing/rspec/spec/unit/outline_unit_spec.rb +7 -0
  62. data/testing/rspec/spec/unit/parsing_unit_spec.rb +33 -0
  63. data/testing/rspec/spec/unit/scenario_unit_spec.rb +7 -0
  64. data/testing/rspec/spec/unit/shared/keyworded_models_unit_specs.rb +58 -0
  65. data/testing/rspec/spec/unit/step_unit_spec.rb +1 -23
  66. data/testing/test_languages.json +45 -0
  67. data/todo.txt +1 -1
  68. metadata +6 -3
@@ -0,0 +1,48 @@
1
+ module CukeModeler
2
+ module DialectHelper
3
+
4
+ def self.set_dialect(dialect)
5
+ @dialect = dialect
6
+ end
7
+
8
+ def self.feature_keyword
9
+ get_word(@dialect['feature'])
10
+ end
11
+
12
+ def self.background_keyword
13
+ get_word(@dialect['background'])
14
+ end
15
+
16
+ def self.scenario_keyword
17
+ get_word(@dialect['scenario'])
18
+ end
19
+
20
+ def self.outline_keyword
21
+ get_word(@dialect['scenarioOutline'] || @dialect['scenario_outline'])
22
+ end
23
+
24
+ def self.example_keyword
25
+ get_word(@dialect['examples'])
26
+ end
27
+
28
+ def self.step_keyword
29
+ get_word(@dialect['given']).strip
30
+ end
31
+
32
+ def self.given_keyword
33
+ get_word(@dialect['given']).strip
34
+ end
35
+
36
+ def self.then_keyword
37
+ get_word(@dialect['then']).strip
38
+ end
39
+
40
+ def self.get_word(word_set)
41
+ word_set.is_a?(Array) ? word_set.first : word_set.split('|').first
42
+ end
43
+
44
+
45
+ private_class_method :get_word
46
+
47
+ end
48
+ end
@@ -15,13 +15,13 @@ describe 'Background, Integration' do
15
15
  describe 'unique behavior' do
16
16
 
17
17
  it 'can be instantiated with the minimum viable Gherkin' do
18
- source = 'Background:'
18
+ source = "#{@background_keyword}:"
19
19
 
20
20
  expect { clazz.new(source) }.to_not raise_error
21
21
  end
22
22
 
23
23
  it 'stores the original data generated by the parsing adapter', :gherkin4 => true do
24
- background = clazz.new("Background: test background\ndescription\n* a step")
24
+ background = clazz.new("#{@background_keyword}: test background\ndescription\n#{@step_keyword} a step")
25
25
  data = background.parsing_data
26
26
 
27
27
  expect(data.keys).to match_array([:type, :location, :keyword, :name, :steps, :description])
@@ -29,7 +29,7 @@ describe 'Background, Integration' do
29
29
  end
30
30
 
31
31
  it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
32
- background = clazz.new("Background: test background\ndescription\n* a step")
32
+ background = clazz.new("#{@background_keyword}: test background\ndescription\n#{@step_keyword} a step")
33
33
  data = background.parsing_data
34
34
 
35
35
  expect(data.keys).to match_array([:type, :location, :keyword, :name, :steps, :description])
@@ -37,7 +37,7 @@ describe 'Background, Integration' do
37
37
  end
38
38
 
39
39
  it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
40
- background = clazz.new("Background: test background\ndescription\n* a step")
40
+ background = clazz.new("#{@background_keyword}: test background\ndescription\n#{@step_keyword} a step")
41
41
  data = background.parsing_data
42
42
 
43
43
  expect(data.keys).to match_array(['keyword', 'name', 'line', 'description', 'steps', 'type'])
@@ -45,15 +45,14 @@ describe 'Background, Integration' do
45
45
  end
46
46
 
47
47
  it 'provides a descriptive filename when being parsed from stand alone text' do
48
- source = "bad background text \n Background:\n And a step\n @foo "
48
+ source = "bad background text \n #{@background_keyword}:\n #{@step_keyword} a step\n @foo "
49
49
 
50
50
  expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_background\.feature'/)
51
51
  end
52
52
 
53
53
  it 'properly sets its child models' do
54
- source = [' Background: Test background',
55
- ' * a step']
56
- source = source.join("\n")
54
+ source = "#{@background_keyword}: Test background
55
+ #{@step_keyword} a step"
57
56
 
58
57
  background = clazz.new(source)
59
58
  step = background.steps.first
@@ -62,7 +61,7 @@ describe 'Background, Integration' do
62
61
  end
63
62
 
64
63
  it 'trims whitespace from its source description' do
65
- source = ['Background:',
64
+ source = ["#{@background_keyword}:",
66
65
  ' ',
67
66
  ' description line 1',
68
67
  '',
@@ -71,11 +70,11 @@ describe 'Background, Integration' do
71
70
  '',
72
71
  '',
73
72
  '',
74
- ' * a step']
73
+ " #{@step_keyword} a step"]
75
74
  source = source.join("\n")
76
75
 
77
76
  background = clazz.new(source)
78
- description = background.description.split("\n")
77
+ description = background.description.split("\n", -1)
79
78
 
80
79
  expect(description).to eq([' description line 1',
81
80
  '',
@@ -87,11 +86,10 @@ describe 'Background, Integration' do
87
86
  describe 'getting ancestors' do
88
87
 
89
88
  before(:each) do
90
- source = ['Feature: Test feature',
91
- '',
92
- ' Background: Test background',
93
- ' * a step:']
94
- source = source.join("\n")
89
+ source = "#{@feature_keyword}: Test feature
90
+
91
+ #{@background_keyword}: Test background
92
+ #{@step_keyword} a step"
95
93
 
96
94
  file_path = "#{@default_file_directory}/background_test_file.feature"
97
95
  File.open(file_path, 'w') { |file| file.write(source) }
@@ -132,11 +130,19 @@ describe 'Background, Integration' do
132
130
 
133
131
  context 'from source text' do
134
132
 
133
+ let(:source_text) { "#{@background_keyword}:" }
134
+ let(:background) { clazz.new(source_text) }
135
+
136
+
137
+ it "models the background's keyword" do
138
+ expect(background.keyword).to eq("#{@background_keyword}")
139
+ end
140
+
135
141
  it "models the background's source line" do
136
- source_text = "Feature:
142
+ source_text = "#{@feature_keyword}:
137
143
 
138
- Background: foo
139
- * step"
144
+ #{@background_keyword}: foo
145
+ #{@step_keyword} step"
140
146
  background = CukeModeler::Feature.new(source_text).background
141
147
 
142
148
  expect(background.source_line).to eq(3)
@@ -144,15 +150,15 @@ describe 'Background, Integration' do
144
150
 
145
151
  context 'a filled background' do
146
152
 
147
- let(:source_text) { "Background: Background name
153
+ let(:source_text) { "#{@background_keyword}: Background name
148
154
 
149
155
  Background description.
150
156
 
151
157
  Some more.
152
158
  Even more.
153
159
 
154
- * a step
155
- * another step" }
160
+ #{@step_keyword} a step
161
+ #{@step_keyword} another step" }
156
162
  let(:background) { clazz.new(source_text) }
157
163
 
158
164
 
@@ -161,7 +167,7 @@ describe 'Background, Integration' do
161
167
  end
162
168
 
163
169
  it "models the background's description" do
164
- description = background.description.split("\n")
170
+ description = background.description.split("\n", -1)
165
171
 
166
172
  expect(description).to eq([' Background description.',
167
173
  '',
@@ -179,7 +185,7 @@ describe 'Background, Integration' do
179
185
 
180
186
  context 'an empty background' do
181
187
 
182
- let(:source_text) { 'Background:' }
188
+ let(:source_text) { "#{@background_keyword}:" }
183
189
  let(:background) { clazz.new(source_text) }
184
190
 
185
191
 
@@ -205,19 +211,19 @@ describe 'Background, Integration' do
205
211
  describe 'comparison' do
206
212
 
207
213
  it 'is equal to a background with the same steps' do
208
- source = "Background:
209
- * step 1
210
- * step 2"
214
+ source = "#{@background_keyword}:
215
+ #{@step_keyword} step 1
216
+ #{@step_keyword} step 2"
211
217
  background_1 = clazz.new(source)
212
218
 
213
- source = "Background:
214
- * step 1
215
- * step 2"
219
+ source = "#{@background_keyword}:
220
+ #{@step_keyword} step 1
221
+ #{@step_keyword} step 2"
216
222
  background_2 = clazz.new(source)
217
223
 
218
- source = "Background:
219
- * step 2
220
- * step 1"
224
+ source = "#{@background_keyword}:
225
+ #{@step_keyword} step 2
226
+ #{@step_keyword} step 1"
221
227
  background_3 = clazz.new(source)
222
228
 
223
229
 
@@ -226,19 +232,19 @@ describe 'Background, Integration' do
226
232
  end
227
233
 
228
234
  it 'is equal to a scenario with the same steps' do
229
- source = "Background:
230
- * step 1
231
- * step 2"
235
+ source = "#{@background_keyword}:
236
+ #{@step_keyword} step 1
237
+ #{@step_keyword} step 2"
232
238
  background = clazz.new(source)
233
239
 
234
- source = "Scenario:
235
- * step 1
236
- * step 2"
240
+ source = "#{@scenario_keyword}:
241
+ #{@step_keyword} step 1
242
+ #{@step_keyword} step 2"
237
243
  scenario_1 = CukeModeler::Scenario.new(source)
238
244
 
239
- source = "Scenario:
240
- * step 2
241
- * step 1"
245
+ source = "#{@scenario_keyword}:
246
+ #{@step_keyword} step 2
247
+ #{@step_keyword} step 1"
242
248
  scenario_2 = CukeModeler::Scenario.new(source)
243
249
 
244
250
 
@@ -247,23 +253,23 @@ describe 'Background, Integration' do
247
253
  end
248
254
 
249
255
  it 'is equal to an outline with the same steps' do
250
- source = "Background:
251
- * step 1
252
- * step 2"
256
+ source = "#{@background_keyword}:
257
+ #{@step_keyword} step 1
258
+ #{@step_keyword} step 2"
253
259
  background = clazz.new(source)
254
260
 
255
- source = "Scenario Outline:
256
- * step 1
257
- * step 2
258
- Examples:
261
+ source = "#{@outline_keyword}:
262
+ #{@step_keyword} step 1
263
+ #{@step_keyword} step 2
264
+ #{@example_keyword}:
259
265
  | param |
260
266
  | value |"
261
267
  outline_1 = CukeModeler::Outline.new(source)
262
268
 
263
- source = "Scenario Outline:
264
- * step 2
265
- * step 1
266
- Examples:
269
+ source = "#{@outline_keyword}:
270
+ #{@step_keyword} step 2
271
+ #{@step_keyword} step 1
272
+ #{@example_keyword}:
267
273
  | param |
268
274
  | value |"
269
275
  outline_2 = CukeModeler::Outline.new(source)
@@ -279,18 +285,17 @@ describe 'Background, Integration' do
279
285
  describe 'background output' do
280
286
 
281
287
  it 'can be remade from its own output' do
282
- source = ['Background: A background with everything it could have',
283
- '',
284
- 'Including a description',
285
- 'and then some.',
286
- '',
287
- ' * a step',
288
- ' | value |',
289
- ' * another step',
290
- ' """',
291
- ' some string',
292
- ' """']
293
- source = source.join("\n")
288
+ source = "#{@background_keyword}: A background with everything it could have
289
+
290
+ Including a description
291
+ and then some.
292
+
293
+ #{@step_keyword} a step
294
+ | value |
295
+ #{@step_keyword} another step
296
+ \"\"\"
297
+ some string
298
+ \"\"\""
294
299
  background = clazz.new(source)
295
300
 
296
301
  background_output = background.to_s
@@ -303,85 +308,85 @@ describe 'Background, Integration' do
303
308
  context 'from source text' do
304
309
 
305
310
  it 'can output an empty background' do
306
- source = ['Background:']
311
+ source = ["#{@background_keyword}:"]
307
312
  source = source.join("\n")
308
313
  background = clazz.new(source)
309
314
 
310
- background_output = background.to_s.split("\n")
315
+ background_output = background.to_s.split("\n", -1)
311
316
 
312
- expect(background_output).to eq(['Background:'])
317
+ expect(background_output).to eq(["#{@background_keyword}:"])
313
318
  end
314
319
 
315
320
  it 'can output a background that has a name' do
316
- source = ['Background: test background']
321
+ source = ["#{@background_keyword}: test background"]
317
322
  source = source.join("\n")
318
323
  background = clazz.new(source)
319
324
 
320
- background_output = background.to_s.split("\n")
325
+ background_output = background.to_s.split("\n", -1)
321
326
 
322
- expect(background_output).to eq(['Background: test background'])
327
+ expect(background_output).to eq(["#{@background_keyword}: test background"])
323
328
  end
324
329
 
325
330
  it 'can output a background that has a description' do
326
- source = ['Background:',
331
+ source = ["#{@background_keyword}:",
327
332
  'Some description.',
328
333
  'Some more description.']
329
334
  source = source.join("\n")
330
335
  background = clazz.new(source)
331
336
 
332
- background_output = background.to_s.split("\n")
337
+ background_output = background.to_s.split("\n", -1)
333
338
 
334
- expect(background_output).to eq(['Background:',
339
+ expect(background_output).to eq(["#{@background_keyword}:",
335
340
  '',
336
341
  'Some description.',
337
342
  'Some more description.'])
338
343
  end
339
344
 
340
345
  it 'can output a background that has steps' do
341
- source = ['Background:',
342
- '* a step',
346
+ source = ["#{@background_keyword}:",
347
+ "#{@step_keyword} a step",
343
348
  '|value|',
344
- '* another step',
349
+ "#{@step_keyword} another step",
345
350
  '"""',
346
351
  'some string',
347
352
  '"""']
348
353
  source = source.join("\n")
349
354
  background = clazz.new(source)
350
355
 
351
- background_output = background.to_s.split("\n")
356
+ background_output = background.to_s.split("\n", -1)
352
357
 
353
- expect(background_output).to eq(['Background:',
354
- ' * a step',
358
+ expect(background_output).to eq(["#{@background_keyword}:",
359
+ " #{@step_keyword} a step",
355
360
  ' | value |',
356
- ' * another step',
361
+ " #{@step_keyword} another step",
357
362
  ' """',
358
363
  ' some string',
359
364
  ' """'])
360
365
  end
361
366
 
362
367
  it 'can output a background that has everything' do
363
- source = ['Background: A background with everything it could have',
368
+ source = ["#{@background_keyword}: A background with everything it could have",
364
369
  'Including a description',
365
370
  'and then some.',
366
- '* a step',
371
+ "#{@step_keyword} a step",
367
372
  '|value|',
368
- '* another step',
373
+ "#{@step_keyword} another step",
369
374
  '"""',
370
375
  'some string',
371
376
  '"""']
372
377
  source = source.join("\n")
373
378
  background = clazz.new(source)
374
379
 
375
- background_output = background.to_s.split("\n")
380
+ background_output = background.to_s.split("\n", -1)
376
381
 
377
- expect(background_output).to eq(['Background: A background with everything it could have',
382
+ expect(background_output).to eq(["#{@background_keyword}: A background with everything it could have",
378
383
  '',
379
384
  'Including a description',
380
385
  'and then some.',
381
386
  '',
382
- ' * a step',
387
+ " #{@step_keyword} a step",
383
388
  ' | value |',
384
- ' * another step',
389
+ " #{@step_keyword} another step",
385
390
  ' """',
386
391
  ' some string',
387
392
  ' """'])
@@ -55,12 +55,11 @@ describe 'Cell, Integration' do
55
55
  describe 'getting ancestors' do
56
56
 
57
57
  before(:each) do
58
- source = ['Feature: Test feature',
59
- '',
60
- ' Scenario: Test test',
61
- ' * a step',
62
- ' | a value |']
63
- source = source.join("\n")
58
+ source = "#{@feature_keyword}: Test feature
59
+
60
+ #{@scenario_keyword}: Test test
61
+ #{@step_keyword} a step
62
+ | a value |"
64
63
 
65
64
  file_path = "#{@default_file_directory}/cell_test_file.feature"
66
65
  File.open(file_path, 'w') { |file| file.write(source) }
@@ -91,13 +90,13 @@ describe 'Cell, Integration' do
91
90
  context 'a cell that is part of an outline' do
92
91
 
93
92
  before(:each) do
94
- source = 'Feature: Test feature
93
+ source = "#{@feature_keyword}: Test feature
95
94
 
96
- Scenario Outline: Test outline
97
- * a step
98
- Examples:
95
+ #{@outline_keyword}: Test outline
96
+ #{@step_keyword} a step
97
+ #{@example_keyword}:
99
98
  | param |
100
- | value |'
99
+ | value |"
101
100
 
102
101
  file_path = "#{@default_file_directory}/cell_test_file.feature"
103
102
  File.open(file_path, 'w') { |file| file.write(source) }
@@ -131,11 +130,11 @@ describe 'Cell, Integration' do
131
130
  context 'a cell that is part of a scenario' do
132
131
 
133
132
  before(:each) do
134
- source = 'Feature: Test feature
133
+ source = "#{@feature_keyword}: Test feature
135
134
 
136
- Scenario: Test test
137
- * a step:
138
- | a | table |'
135
+ #{@scenario_keyword}: Test test
136
+ #{@step_keyword} a step:
137
+ | a | table |"
139
138
 
140
139
  file_path = "#{@default_file_directory}/cell_test_file.feature"
141
140
  File.open(file_path, 'w') { |file| file.write(source) }
@@ -156,11 +155,11 @@ describe 'Cell, Integration' do
156
155
  context 'a cell that is part of a background' do
157
156
 
158
157
  before(:each) do
159
- source = 'Feature: Test feature
158
+ source = "#{@feature_keyword}: Test feature
160
159
 
161
- Background: Test background
162
- * a step:
163
- | a | table |'
160
+ #{@background_keyword}: Test background
161
+ #{@step_keyword} a step:
162
+ | a | table |"
164
163
 
165
164
  file_path = "#{@default_file_directory}/cell_test_file.feature"
166
165
  File.open(file_path, 'w') { |file| file.write(source) }
@@ -181,11 +180,11 @@ describe 'Cell, Integration' do
181
180
  context 'a cell that is part of a step' do
182
181
 
183
182
  before(:each) do
184
- source = 'Feature: Test feature
183
+ source = "#{@feature_keyword}: Test feature
185
184
 
186
- Scenario: Test test
187
- * a step:
188
- | a | table |'
185
+ #{@scenario_keyword}: Test test
186
+ #{@step_keyword} a step:
187
+ | a | table |"
189
188
 
190
189
  file_path = "#{@default_file_directory}/cell_test_file.feature"
191
190
  File.open(file_path, 'w') { |file| file.write(source) }
@@ -237,11 +236,11 @@ describe 'Cell, Integration' do
237
236
  end
238
237
 
239
238
  it "models the cell's source line" do
240
- source_text = 'Feature:
239
+ source_text = "#{@feature_keyword}:
241
240
 
242
- Scenario:
243
- * a step
244
- | value |'
241
+ #{@scenario_keyword}:
242
+ #{@step_keyword} a step
243
+ | value |"
245
244
  cell = CukeModeler::Feature.new(source_text).tests.first.steps.first.block.rows.first.cells.first
246
245
 
247
246
  expect(cell.source_line).to eq(5)