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.
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
@@ -15,7 +15,7 @@ describe 'Step, Integration' do
15
15
  describe 'unique behavior' do
16
16
 
17
17
  it 'can be instantiated with the minimum viable Gherkin' do
18
- source = '* a step'
18
+ source = "#{@step_keyword} a step"
19
19
 
20
20
  expect { clazz.new(source) }.to_not raise_error
21
21
  end
@@ -27,7 +27,7 @@ describe 'Step, Integration' do
27
27
  end
28
28
 
29
29
  it 'stores the original data generated by the parsing adapter (with a table)', :gherkin4 => true do
30
- step = clazz.new("* test step\n|table|")
30
+ step = clazz.new("#{@step_keyword} test step\n|table|")
31
31
  data = step.parsing_data
32
32
 
33
33
  expect(data.keys).to match_array([:type, :location, :keyword, :text, :argument])
@@ -35,7 +35,7 @@ describe 'Step, Integration' do
35
35
  end
36
36
 
37
37
  it 'stores the original data generated by the parsing adapter (with a doc string)', :gherkin4 => true do
38
- step = clazz.new("* test step\n\"\"\"\na doc string\n\"\"\"")
38
+ step = clazz.new("#{@step_keyword} test step\n\"\"\"\na doc string\n\"\"\"")
39
39
  data = step.parsing_data
40
40
 
41
41
  expect(data.keys).to match_array([:type, :location, :keyword, :text, :argument])
@@ -43,7 +43,7 @@ describe 'Step, Integration' do
43
43
  end
44
44
 
45
45
  it 'stores the original data generated by the parsing adapter (with a table)', :gherkin3 => true do
46
- step = clazz.new("* test step\n|table|")
46
+ step = clazz.new("#{@step_keyword} test step\n|table|")
47
47
  data = step.parsing_data
48
48
 
49
49
  expect(data.keys).to match_array([:type, :location, :keyword, :text, :argument])
@@ -51,7 +51,7 @@ describe 'Step, Integration' do
51
51
  end
52
52
 
53
53
  it 'stores the original data generated by the parsing adapter (with a doc string)', :gherkin3 => true do
54
- step = clazz.new("* test step\n\"\"\"\na doc string\n\"\"\"")
54
+ step = clazz.new("#{@step_keyword} test step\n\"\"\"\na doc string\n\"\"\"")
55
55
  data = step.parsing_data
56
56
 
57
57
  expect(data.keys).to match_array([:type, :location, :keyword, :text, :argument])
@@ -59,31 +59,31 @@ describe 'Step, Integration' do
59
59
  end
60
60
 
61
61
  it 'stores the original data generated by the parsing adapter (with a table)', :gherkin2 => true do
62
- step = clazz.new("* test step\n|table|")
62
+ step = clazz.new("#{@step_keyword} test step\n|table|")
63
63
  data = step.parsing_data
64
64
 
65
65
  expect(data.keys).to match_array(['keyword', 'name', 'line', 'rows'])
66
- expect(data['keyword']).to eq('* ')
66
+ expect(data['keyword']).to eq("#{@step_keyword} ")
67
67
  end
68
68
 
69
69
  it 'stores the original data generated by the parsing adapter (with a doc string)', :gherkin2 => true do
70
- step = clazz.new("* test step\n\"\"\"\na doc string\n\"\"\"")
70
+ step = clazz.new("#{@step_keyword} test step\n\"\"\"\na doc string\n\"\"\"")
71
71
  data = step.parsing_data
72
72
 
73
73
  expect(data.keys).to match_array(['keyword', 'name', 'line', 'doc_string'])
74
- expect(data['keyword']).to eq('* ')
74
+ expect(data['keyword']).to eq("#{@step_keyword} ")
75
75
  end
76
76
 
77
77
  describe 'model population' do
78
78
 
79
79
  context 'from source text' do
80
80
 
81
- let(:source_text) { '* a step' }
81
+ let(:source_text) { "#{@step_keyword} a step" }
82
82
  let(:step) { clazz.new(source_text) }
83
83
 
84
84
 
85
85
  it "models the step's keyword" do
86
- expect(step.keyword).to eq('*')
86
+ expect(step.keyword).to eq("#{@step_keyword}")
87
87
  end
88
88
 
89
89
  it "models the step's text" do
@@ -91,10 +91,10 @@ describe 'Step, Integration' do
91
91
  end
92
92
 
93
93
  it "models the step's source line" do
94
- source_text = "Feature:
94
+ source_text = "#{@feature_keyword}:
95
95
 
96
- Scenario: foo
97
- * step"
96
+ #{@scenario_keyword}: foo
97
+ #{@step_keyword} step"
98
98
  step = CukeModeler::Feature.new(source_text).tests.first.steps.first
99
99
 
100
100
  expect(step.source_line).to eq(4)
@@ -103,7 +103,7 @@ describe 'Step, Integration' do
103
103
 
104
104
  context 'with no block' do
105
105
 
106
- let(:source_text) { '* a step' }
106
+ let(:source_text) { "#{@step_keyword} a step" }
107
107
  let(:step) { clazz.new(source_text) }
108
108
 
109
109
 
@@ -115,9 +115,9 @@ describe 'Step, Integration' do
115
115
 
116
116
  context 'a step with a table' do
117
117
 
118
- let(:source_text) { '* a step
118
+ let(:source_text) { "#{@step_keyword} a step
119
119
  | value 1 |
120
- | value 2 |' }
120
+ | value 2 |" }
121
121
  let(:step) { clazz.new(source_text) }
122
122
 
123
123
 
@@ -131,10 +131,10 @@ describe 'Step, Integration' do
131
131
 
132
132
  context 'a step with a doc string' do
133
133
 
134
- let(:source_text) { '* a step
135
- """
134
+ let(:source_text) { "#{@step_keyword} a step
135
+ \"\"\"
136
136
  some text
137
- """' }
137
+ \"\"\"" }
138
138
  let(:step) { clazz.new(source_text) }
139
139
 
140
140
 
@@ -152,15 +152,15 @@ describe 'Step, Integration' do
152
152
 
153
153
 
154
154
  it 'properly sets its child models' do
155
- source_1 = ['* a step',
156
- '"""',
157
- 'a doc string',
158
- '"""']
159
- source_2 = ['* a step',
160
- '| a block|']
155
+ source_1 = "#{@step_keyword} a step
156
+ \"\"\"
157
+ a doc string
158
+ \"\"\""
159
+ source_2 = "#{@step_keyword} a step
160
+ | a block|"
161
161
 
162
- step_1 = clazz.new(source_1.join("\n"))
163
- step_2 = clazz.new(source_2.join("\n"))
162
+ step_1 = clazz.new(source_1)
163
+ step_2 = clazz.new(source_2)
164
164
 
165
165
 
166
166
  doc_string = step_1.block
@@ -174,9 +174,9 @@ describe 'Step, Integration' do
174
174
  describe 'step comparison' do
175
175
 
176
176
  it 'is equal to another Step that has the same text' do
177
- source_1 = '* a step'
178
- source_2 = '* a step'
179
- source_3 = '* a different step'
177
+ source_1 = "#{@step_keyword} a step"
178
+ source_2 = "#{@step_keyword} a step"
179
+ source_3 = "#{@step_keyword} a different step"
180
180
 
181
181
  step_1 = clazz.new(source_1)
182
182
  step_2 = clazz.new(source_2)
@@ -188,8 +188,8 @@ describe 'Step, Integration' do
188
188
  end
189
189
 
190
190
  it 'ignores steps keywords when comparing steps' do
191
- source_1 = 'Given a step'
192
- source_2 = 'Then a step'
191
+ source_1 = "#{@given_keyword} a step"
192
+ source_2 = "#{@then_keyword} a step"
193
193
 
194
194
  step_1 = clazz.new(source_1)
195
195
  step_2 = clazz.new(source_2)
@@ -199,8 +199,8 @@ describe 'Step, Integration' do
199
199
  end
200
200
 
201
201
  it 'ignores step tables when comparing steps' do
202
- source_1 = '* a step'
203
- source_2 = "* a step\n|with a table|"
202
+ source_1 = "#{@step_keyword} a step"
203
+ source_2 = "#{@step_keyword} a step\n|with a table|"
204
204
 
205
205
  step_1 = clazz.new(source_1)
206
206
  step_2 = clazz.new(source_2)
@@ -210,8 +210,8 @@ describe 'Step, Integration' do
210
210
  end
211
211
 
212
212
  it 'ignores step doc strings when comparing steps' do
213
- source_1 = '* a step'
214
- source_2 = "* a step\n\"\"\"\nwith a doc string\n\"\"\""
213
+ source_1 = "#{@step_keyword} a step"
214
+ source_2 = "#{@step_keyword} a step\n\"\"\"\nwith a doc string\n\"\"\""
215
215
 
216
216
 
217
217
  step_1 = clazz.new(source_1)
@@ -227,11 +227,10 @@ describe 'Step, Integration' do
227
227
  describe 'getting ancestors' do
228
228
 
229
229
  before(:each) do
230
- source = ['Feature: Test feature',
231
- '',
232
- ' Scenario: Test test',
233
- ' * a step:']
234
- source = source.join("\n")
230
+ source = "#{@feature_keyword}: Test feature
231
+
232
+ #{@scenario_keyword}: Test test
233
+ #{@step_keyword} a step:"
235
234
 
236
235
  file_path = "#{@default_file_directory}/step_test_file.feature"
237
236
  File.open(file_path, 'w') { |file| file.write(source) }
@@ -263,10 +262,10 @@ describe 'Step, Integration' do
263
262
  context 'a step that is part of a scenario' do
264
263
 
265
264
  before(:each) do
266
- source = 'Feature: Test feature
265
+ source = "#{@feature_keyword}: Test feature
267
266
 
268
- Scenario: Test scenario
269
- * a step'
267
+ #{@scenario_keyword}: Test scenario
268
+ #{@step_keyword} a step"
270
269
 
271
270
  file_path = "#{@default_file_directory}/step_test_file.feature"
272
271
  File.open(file_path, 'w') { |file| file.write(source) }
@@ -287,13 +286,13 @@ describe 'Step, Integration' do
287
286
  context 'a step that is part of an outline' do
288
287
 
289
288
  before(:each) do
290
- source = 'Feature: Test feature
289
+ source = "#{@feature_keyword}: Test feature
291
290
 
292
- Scenario Outline: Test outline
293
- * a step
294
- Examples:
291
+ #{@outline_keyword}: Test outline
292
+ #{@step_keyword} a step
293
+ #{@example_keyword}:
295
294
  | param |
296
- | value |'
295
+ | value |"
297
296
 
298
297
  file_path = "#{@default_file_directory}/step_test_file.feature"
299
298
  File.open(file_path, 'w') { |file| file.write(source) }
@@ -314,10 +313,10 @@ describe 'Step, Integration' do
314
313
  context 'a step that is part of a background' do
315
314
 
316
315
  before(:each) do
317
- source = 'Feature: Test feature
316
+ source = "#{@feature_keyword}: Test feature
318
317
 
319
- Background: Test background
320
- * a step'
318
+ #{@background_keyword}: Test background
319
+ #{@step_keyword} a step"
321
320
 
322
321
  file_path = "#{@default_file_directory}/step_test_file.feature"
323
322
  File.open(file_path, 'w') { |file| file.write(source) }
@@ -350,30 +349,36 @@ describe 'Step, Integration' do
350
349
 
351
350
  context 'with no block' do
352
351
 
352
+ let(:source_text) { ["#{@step_keyword} a step"].join("\n") }
353
+ let(:step) { clazz.new(source_text) }
354
+
353
355
  it 'can output a step' do
354
- source = ['* a step']
355
- source = source.join("\n")
356
- step = clazz.new(source)
356
+ step_output = step.to_s.split("\n", -1)
357
357
 
358
- step_output = step.to_s.split("\n")
358
+ expect(step_output).to eq(["#{@step_keyword} a step"])
359
+ end
359
360
 
360
- expect(step_output).to eq(['* a step'])
361
+ it 'can be remade from its own output' do
362
+ step_output = step.to_s
363
+ remade_step_output = clazz.new(step_output).to_s
364
+
365
+ expect(remade_step_output).to eq(step_output)
361
366
  end
362
367
 
363
368
  end
364
369
 
365
370
  context 'a step with a table' do
366
371
 
367
- let(:source_text) { ['* a step',
372
+ let(:source_text) { ["#{@step_keyword} a step",
368
373
  ' | value1 | value2 |',
369
374
  ' | value3 | value4 |'].join("\n") }
370
375
  let(:step) { clazz.new(source_text) }
371
376
 
372
377
 
373
378
  it 'can output a step that has a table' do
374
- step_output = step.to_s.split("\n")
379
+ step_output = step.to_s.split("\n", -1)
375
380
 
376
- expect(step_output).to eq(['* a step',
381
+ expect(step_output).to eq(["#{@step_keyword} a step",
377
382
  ' | value1 | value2 |',
378
383
  ' | value3 | value4 |'])
379
384
 
@@ -390,7 +395,7 @@ describe 'Step, Integration' do
390
395
 
391
396
  context 'a step with a doc string' do
392
397
 
393
- let(:source_text) { ['* a step',
398
+ let(:source_text) { ["#{@step_keyword} a step",
394
399
  ' """',
395
400
  ' some text',
396
401
  ' """'].join("\n") }
@@ -398,9 +403,9 @@ describe 'Step, Integration' do
398
403
 
399
404
 
400
405
  it 'can output a step that has a doc string' do
401
- step_output = step.to_s.split("\n")
406
+ step_output = step.to_s.split("\n", -1)
402
407
 
403
- expect(step_output).to eq(['* a step',
408
+ expect(step_output).to eq(["#{@step_keyword} a step",
404
409
  ' """',
405
410
  ' some text',
406
411
  ' """'])
@@ -57,10 +57,10 @@ describe 'Table, Integration' do
57
57
  context 'from source text' do
58
58
 
59
59
  it "models the table's source line" do
60
- source_text = "Feature:
60
+ source_text = "#{@feature_keyword}:
61
61
 
62
- Scenario:
63
- * step
62
+ #{@scenario_keyword}:
63
+ #{@step_keyword} step
64
64
  | value |"
65
65
  table = CukeModeler::Feature.new(source_text).tests.first.steps.first.block
66
66
 
@@ -89,9 +89,8 @@ describe 'Table, Integration' do
89
89
 
90
90
 
91
91
  it 'properly sets its child models' do
92
- source = ['| cell 1 |',
93
- '| cell 2 |']
94
- source = source.join("\n")
92
+ source = "| cell 1 |
93
+ | cell 2 |"
95
94
 
96
95
  table = clazz.new(source)
97
96
  row_1 = table.rows[0]
@@ -104,12 +103,11 @@ describe 'Table, Integration' do
104
103
  describe 'getting ancestors' do
105
104
 
106
105
  before(:each) do
107
- source = ['Feature: Test feature',
108
- '',
109
- ' Scenario: Test test',
110
- ' * a step:',
111
- ' | a | table |']
112
- source = source.join("\n")
106
+ source = "#{@feature_keyword}: Test feature
107
+
108
+ #{@scenario_keyword}: Test test
109
+ #{@step_keyword} a step:
110
+ | a | table |"
113
111
 
114
112
  file_path = "#{@default_file_directory}/table_test_file.feature"
115
113
  File.open(file_path, 'w') { |file| file.write(source) }
@@ -140,11 +138,11 @@ describe 'Table, Integration' do
140
138
  context 'a table that is part of a scenario' do
141
139
 
142
140
  before(:each) do
143
- source = 'Feature: Test feature
141
+ source = "#{@feature_keyword}: Test feature
144
142
 
145
- Scenario: Test test
146
- * a step:
147
- | a | table |'
143
+ #{@scenario_keyword}: Test test
144
+ #{@step_keyword} a step:
145
+ | a | table |"
148
146
 
149
147
  file_path = "#{@default_file_directory}/table_test_file.feature"
150
148
  File.open(file_path, 'w') { |file| file.write(source) }
@@ -165,14 +163,14 @@ describe 'Table, Integration' do
165
163
  context 'a table that is part of an outline' do
166
164
 
167
165
  before(:each) do
168
- source = 'Feature: Test feature
166
+ source = "#{@feature_keyword}: Test feature
169
167
 
170
- Scenario Outline: Test outline
171
- * a step:
168
+ #{@outline_keyword}: Test outline
169
+ #{@step_keyword} a step:
172
170
  | a | table |
173
- Examples:
171
+ #{@example_keyword}:
174
172
  | param |
175
- | value |'
173
+ | value |"
176
174
 
177
175
  file_path = "#{@default_file_directory}/table_test_file.feature"
178
176
  File.open(file_path, 'w') { |file| file.write(source) }
@@ -193,11 +191,11 @@ describe 'Table, Integration' do
193
191
  context 'a table that is part of a background' do
194
192
 
195
193
  before(:each) do
196
- source = 'Feature: Test feature
194
+ source = "#{@feature_keyword}: Test feature
197
195
 
198
- Background: Test background
199
- * a step:
200
- | a | table |'
196
+ #{@background_keyword}: Test background
197
+ #{@step_keyword} a step:
198
+ | a | table |"
201
199
 
202
200
  file_path = "#{@default_file_directory}/table_test_file.feature"
203
201
  File.open(file_path, 'w') { |file| file.write(source) }
@@ -233,9 +231,8 @@ describe 'Table, Integration' do
233
231
  describe 'table output' do
234
232
 
235
233
  it 'can be remade from its own output' do
236
- source = ['| value1 | value2 |',
237
- '| value3 | value4 |']
238
- source = source.join("\n")
234
+ source = "| value1 | value2 |
235
+ | value3 | value4 |"
239
236
  table = clazz.new(source)
240
237
 
241
238
  table_output = table.to_s
@@ -255,7 +252,7 @@ describe 'Table, Integration' do
255
252
  source = source.join("\n")
256
253
  table = clazz.new(source)
257
254
 
258
- table_output = table.to_s.split("\n")
255
+ table_output = table.to_s.split("\n", -1)
259
256
 
260
257
  expect(table_output).to eq(['| a value with \| |',
261
258
  '| a value with \\\\ |',
@@ -269,7 +266,7 @@ describe 'Table, Integration' do
269
266
  source = source.join("\n")
270
267
  table = clazz.new(source)
271
268
 
272
- table_output = table.to_s.split("\n")
269
+ table_output = table.to_s.split("\n", -1)
273
270
 
274
271
  expect(table_output).to eq(['| value1 | value2 |'])
275
272
  end
@@ -280,20 +277,19 @@ describe 'Table, Integration' do
280
277
  source = source.join("\n")
281
278
  table = clazz.new(source)
282
279
 
283
- table_output = table.to_s.split("\n")
280
+ table_output = table.to_s.split("\n", -1)
284
281
 
285
282
  expect(table_output).to eq(['| value1 | value2 |',
286
283
  '| value3 | value4 |'])
287
284
  end
288
285
 
289
286
  it 'buffers row cells based on the longest value in a column' do
290
- source = ['|value 1| x|',
291
- '|y|value 2|',
292
- '|a|b|']
293
- source = source.join("\n")
287
+ source = "|value 1| x|
288
+ |y|value 2|
289
+ |a|b|"
294
290
  table = clazz.new(source)
295
291
 
296
- table_output = table.to_s.split("\n")
292
+ table_output = table.to_s.split("\n", -1)
297
293
 
298
294
  expect(table_output).to eq(['| value 1 | x |',
299
295
  '| y | value 2 |',