cuke_modeler 2.1.0 → 3.4.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 (146) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +53 -1
  3. data/README.md +14 -16
  4. data/cuke_modeler.gemspec +33 -21
  5. data/lib/cuke_modeler.rb +2 -1
  6. data/lib/cuke_modeler/adapters/gherkin_10_adapter.rb +13 -0
  7. data/lib/cuke_modeler/adapters/gherkin_11_adapter.rb +13 -0
  8. data/lib/cuke_modeler/adapters/gherkin_12_adapter.rb +13 -0
  9. data/lib/cuke_modeler/adapters/gherkin_13_adapter.rb +13 -0
  10. data/lib/cuke_modeler/adapters/gherkin_14_adapter.rb +13 -0
  11. data/lib/cuke_modeler/adapters/gherkin_15_adapter.rb +13 -0
  12. data/lib/cuke_modeler/adapters/gherkin_9_adapter.rb +356 -4
  13. data/lib/cuke_modeler/containing.rb +41 -89
  14. data/lib/cuke_modeler/described.rb +40 -1
  15. data/lib/cuke_modeler/models/background.rb +12 -12
  16. data/lib/cuke_modeler/models/cell.rb +14 -8
  17. data/lib/cuke_modeler/models/comment.rb +6 -6
  18. data/lib/cuke_modeler/models/directory.rb +14 -18
  19. data/lib/cuke_modeler/models/doc_string.rb +11 -8
  20. data/lib/cuke_modeler/models/example.rb +64 -46
  21. data/lib/cuke_modeler/models/feature.rb +38 -20
  22. data/lib/cuke_modeler/models/feature_file.rb +6 -8
  23. data/lib/cuke_modeler/models/model.rb +2 -1
  24. data/lib/cuke_modeler/models/outline.rb +20 -15
  25. data/lib/cuke_modeler/models/row.rb +11 -8
  26. data/lib/cuke_modeler/models/rule.rb +101 -0
  27. data/lib/cuke_modeler/models/scenario.rb +18 -13
  28. data/lib/cuke_modeler/models/step.rb +41 -19
  29. data/lib/cuke_modeler/models/table.rb +10 -7
  30. data/lib/cuke_modeler/models/tag.rb +10 -6
  31. data/lib/cuke_modeler/named.rb +5 -1
  32. data/lib/cuke_modeler/nested.rb +22 -18
  33. data/lib/cuke_modeler/parsed.rb +8 -0
  34. data/lib/cuke_modeler/parsing.rb +55 -74
  35. data/lib/cuke_modeler/sourceable.rb +8 -0
  36. data/lib/cuke_modeler/stepped.rb +8 -0
  37. data/lib/cuke_modeler/taggable.rb +9 -1
  38. data/lib/cuke_modeler/version.rb +1 -1
  39. data/testing/cucumber/features/modeling/feature_modeling.feature +28 -7
  40. data/testing/cucumber/features/modeling/feature_output.feature +45 -23
  41. data/testing/cucumber/features/modeling/rule_modeling.feature +108 -0
  42. data/testing/cucumber/features/modeling/rule_output.feature +111 -0
  43. metadata +68 -161
  44. data/.gitignore +0 -18
  45. data/.simplecov +0 -7
  46. data/.travis.yml +0 -81
  47. data/Gemfile +0 -44
  48. data/Rakefile +0 -73
  49. data/appveyor.yml +0 -88
  50. data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +0 -274
  51. data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +0 -297
  52. data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +0 -309
  53. data/lib/cuke_modeler/adapters/gherkin_5_adapter.rb +0 -12
  54. data/lib/cuke_modeler/adapters/gherkin_6_adapter.rb +0 -310
  55. data/lib/cuke_modeler/adapters/gherkin_7_adapter.rb +0 -307
  56. data/lib/cuke_modeler/adapters/gherkin_8_adapter.rb +0 -12
  57. data/testing/cucumber/step_definitions/action_steps.rb +0 -13
  58. data/testing/cucumber/step_definitions/background_steps.rb +0 -1
  59. data/testing/cucumber/step_definitions/directory_steps.rb +0 -6
  60. data/testing/cucumber/step_definitions/doc_string_steps.rb +0 -1
  61. data/testing/cucumber/step_definitions/feature_file_steps.rb +0 -16
  62. data/testing/cucumber/step_definitions/feature_steps.rb +0 -7
  63. data/testing/cucumber/step_definitions/modeling_steps.rb +0 -49
  64. data/testing/cucumber/step_definitions/setup_steps.rb +0 -32
  65. data/testing/cucumber/step_definitions/step_steps.rb +0 -3
  66. data/testing/cucumber/step_definitions/table_steps.rb +0 -1
  67. data/testing/cucumber/step_definitions/tag_steps.rb +0 -3
  68. data/testing/cucumber/step_definitions/verification_steps.rb +0 -181
  69. data/testing/cucumber/support/env.rb +0 -30
  70. data/testing/dialect_helper.rb +0 -48
  71. data/testing/file_helper.rb +0 -47
  72. data/testing/gemfiles/gherkin2.gemfile +0 -33
  73. data/testing/gemfiles/gherkin3.gemfile +0 -26
  74. data/testing/gemfiles/gherkin4.gemfile +0 -27
  75. data/testing/gemfiles/gherkin5.gemfile +0 -27
  76. data/testing/gemfiles/gherkin6.gemfile +0 -10
  77. data/testing/gemfiles/gherkin7.gemfile +0 -9
  78. data/testing/gemfiles/gherkin8.gemfile +0 -9
  79. data/testing/gemfiles/gherkin9.gemfile +0 -9
  80. data/testing/helper_methods.rb +0 -23
  81. data/testing/rspec/spec/integration/adapters/gherkin_2_adapter_spec.rb +0 -166
  82. data/testing/rspec/spec/integration/adapters/gherkin_3_adapter_spec.rb +0 -166
  83. data/testing/rspec/spec/integration/adapters/gherkin_4_adapter_spec.rb +0 -165
  84. data/testing/rspec/spec/integration/adapters/gherkin_5_adapter_spec.rb +0 -165
  85. data/testing/rspec/spec/integration/adapters/gherkin_6_adapter_spec.rb +0 -159
  86. data/testing/rspec/spec/integration/adapters/gherkin_7_adapter_spec.rb +0 -162
  87. data/testing/rspec/spec/integration/adapters/gherkin_8_adapter_spec.rb +0 -162
  88. data/testing/rspec/spec/integration/adapters/gherkin_9_adapter_spec.rb +0 -162
  89. data/testing/rspec/spec/integration/models/background_integration_spec.rb +0 -438
  90. data/testing/rspec/spec/integration/models/cell_integration_spec.rb +0 -338
  91. data/testing/rspec/spec/integration/models/comment_integration_spec.rb +0 -180
  92. data/testing/rspec/spec/integration/models/directory_integration_spec.rb +0 -218
  93. data/testing/rspec/spec/integration/models/doc_string_integration_spec.rb +0 -398
  94. data/testing/rspec/spec/integration/models/example_integration_spec.rb +0 -753
  95. data/testing/rspec/spec/integration/models/feature_file_integration_spec.rb +0 -276
  96. data/testing/rspec/spec/integration/models/feature_integration_spec.rb +0 -655
  97. data/testing/rspec/spec/integration/models/model_integration_spec.rb +0 -15
  98. data/testing/rspec/spec/integration/models/outline_integration_spec.rb +0 -619
  99. data/testing/rspec/spec/integration/models/row_integration_spec.rb +0 -303
  100. data/testing/rspec/spec/integration/models/scenario_integration_spec.rb +0 -475
  101. data/testing/rspec/spec/integration/models/step_integration_spec.rb +0 -573
  102. data/testing/rspec/spec/integration/models/table_integration_spec.rb +0 -333
  103. data/testing/rspec/spec/integration/models/tag_integration_spec.rb +0 -271
  104. data/testing/rspec/spec/integration/nested_integration_spec.rb +0 -91
  105. data/testing/rspec/spec/integration/parsing_integration_spec.rb +0 -143
  106. data/testing/rspec/spec/integration/shared/models_integration_specs.rb +0 -18
  107. data/testing/rspec/spec/spec_helper.rb +0 -129
  108. data/testing/rspec/spec/unit/cuke_modeler_unit_spec.rb +0 -25
  109. data/testing/rspec/spec/unit/described_unit_spec.rb +0 -23
  110. data/testing/rspec/spec/unit/models/background_unit_spec.rb +0 -83
  111. data/testing/rspec/spec/unit/models/cell_unit_spec.rb +0 -68
  112. data/testing/rspec/spec/unit/models/comment_unit_spec.rb +0 -68
  113. data/testing/rspec/spec/unit/models/directory_unit_spec.rb +0 -127
  114. data/testing/rspec/spec/unit/models/doc_string_unit_spec.rb +0 -100
  115. data/testing/rspec/spec/unit/models/example_unit_spec.rb +0 -133
  116. data/testing/rspec/spec/unit/models/feature_file_unit_spec.rb +0 -125
  117. data/testing/rspec/spec/unit/models/feature_unit_spec.rb +0 -157
  118. data/testing/rspec/spec/unit/models/model_unit_spec.rb +0 -15
  119. data/testing/rspec/spec/unit/models/outline_unit_spec.rb +0 -117
  120. data/testing/rspec/spec/unit/models/row_unit_spec.rb +0 -68
  121. data/testing/rspec/spec/unit/models/scenario_unit_spec.rb +0 -86
  122. data/testing/rspec/spec/unit/models/step_unit_spec.rb +0 -109
  123. data/testing/rspec/spec/unit/models/table_unit_spec.rb +0 -77
  124. data/testing/rspec/spec/unit/models/tag_unit_spec.rb +0 -68
  125. data/testing/rspec/spec/unit/named_unit_spec.rb +0 -23
  126. data/testing/rspec/spec/unit/nested_unit_spec.rb +0 -43
  127. data/testing/rspec/spec/unit/parsed_unit_spec.rb +0 -27
  128. data/testing/rspec/spec/unit/parsing_unit_spec.rb +0 -54
  129. data/testing/rspec/spec/unit/shared/bare_bones_models_unit_specs.rb +0 -14
  130. data/testing/rspec/spec/unit/shared/containing_models_unit_specs.rb +0 -127
  131. data/testing/rspec/spec/unit/shared/described_models_unit_specs.rb +0 -38
  132. data/testing/rspec/spec/unit/shared/keyworded_models_unit_specs.rb +0 -58
  133. data/testing/rspec/spec/unit/shared/models_unit_specs.rb +0 -15
  134. data/testing/rspec/spec/unit/shared/named_models_unit_specs.rb +0 -39
  135. data/testing/rspec/spec/unit/shared/nested_models_unit_specs.rb +0 -51
  136. data/testing/rspec/spec/unit/shared/parsed_models_unit_specs.rb +0 -39
  137. data/testing/rspec/spec/unit/shared/prepopulated_models_unit_specs.rb +0 -18
  138. data/testing/rspec/spec/unit/shared/sourced_models_unit_specs.rb +0 -39
  139. data/testing/rspec/spec/unit/shared/stepped_models_unit_specs.rb +0 -46
  140. data/testing/rspec/spec/unit/shared/stringifiable_models_unit_specs.rb +0 -18
  141. data/testing/rspec/spec/unit/shared/tagged_models_unit_specs.rb +0 -72
  142. data/testing/rspec/spec/unit/sourceable_unit_spec.rb +0 -27
  143. data/testing/rspec/spec/unit/stepped_unit_spec.rb +0 -23
  144. data/testing/rspec/spec/unit/taggable_unit_spec.rb +0 -69
  145. data/testing/test_languages.json +0 -45
  146. data/todo.txt +0 -25
@@ -1,438 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/../../spec_helper"
2
-
3
-
4
- describe 'Background, Integration' do
5
-
6
- let(:clazz) { CukeModeler::Background }
7
-
8
-
9
- describe 'common behavior' do
10
-
11
- it_should_behave_like 'a model, integration'
12
-
13
- end
14
-
15
- describe 'unique behavior' do
16
-
17
- it 'can be instantiated with the minimum viable Gherkin' do
18
- source = "#{BACKGROUND_KEYWORD}:"
19
-
20
- expect { clazz.new(source) }.to_not raise_error
21
- end
22
-
23
- it 'can parse text that uses a non-default dialect' do
24
- original_dialect = CukeModeler::Parsing.dialect
25
- CukeModeler::Parsing.dialect = 'en-au'
26
-
27
- begin
28
- source_text = 'First off: Background name'
29
-
30
- expect { @model = clazz.new(source_text) }.to_not raise_error
31
-
32
- # Sanity check in case modeling failed in a non-explosive manner
33
- expect(@model.name).to eq('Background name')
34
- ensure
35
- # Making sure that our changes don't escape a test and ruin the rest of the suite
36
- CukeModeler::Parsing.dialect = original_dialect
37
- end
38
- end
39
-
40
- describe 'parsing data' do
41
-
42
- it 'stores the original data generated by the parsing adapter', :if => gherkin?(6, 7, 8, 9) do
43
- background = clazz.new("#{BACKGROUND_KEYWORD}: test background\ndescription\n#{STEP_KEYWORD} a step")
44
- data = background.parsing_data
45
-
46
- expect(data.keys).to match_array([:background, :rule, :scenario])
47
- expect(data[:background][:name]).to eq('test background')
48
- end
49
-
50
- it 'stores the original data generated by the parsing adapter', :if => gherkin?(3, 4, 5) do
51
- background = clazz.new("#{BACKGROUND_KEYWORD}: test background\ndescription\n#{STEP_KEYWORD} a step")
52
- data = background.parsing_data
53
-
54
- expect(data.keys).to match_array([:type, :location, :keyword, :name, :steps, :description])
55
- expect(data[:type]).to eq(:Background)
56
- end
57
-
58
- it 'stores the original data generated by the parsing adapter', :if => gherkin?(2) do
59
- background = clazz.new("#{BACKGROUND_KEYWORD}: test background\ndescription\n#{STEP_KEYWORD} a step")
60
- data = background.parsing_data
61
-
62
- expect(data.keys).to match_array(['keyword', 'name', 'line', 'description', 'steps', 'type'])
63
- expect(data['keyword']).to eq('Background')
64
- end
65
-
66
- end
67
-
68
- it 'provides a descriptive filename when being parsed from stand alone text' do
69
- source = "bad background text \n #{BACKGROUND_KEYWORD}:\n #{STEP_KEYWORD} a step\n @foo "
70
-
71
- expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_background\.feature'/)
72
- end
73
-
74
- it 'properly sets its child models' do
75
- source = "#{BACKGROUND_KEYWORD}: Test background
76
- #{STEP_KEYWORD} a step"
77
-
78
- background = clazz.new(source)
79
- step = background.steps.first
80
-
81
- expect(step.parent_model).to equal(background)
82
- end
83
-
84
- it 'trims whitespace from its source description' do
85
- source = ["#{BACKGROUND_KEYWORD}:",
86
- ' ',
87
- ' description line 1',
88
- '',
89
- ' description line 2',
90
- ' description line 3 ',
91
- '',
92
- '',
93
- '',
94
- " #{STEP_KEYWORD} a step"]
95
- source = source.join("\n")
96
-
97
- background = clazz.new(source)
98
- description = background.description.split("\n", -1)
99
-
100
- expect(description).to eq([' description line 1',
101
- '',
102
- 'description line 2',
103
- ' description line 3'])
104
- end
105
-
106
-
107
- describe 'getting ancestors' do
108
-
109
- before(:each) do
110
- CukeModeler::FileHelper.create_feature_file(:text => source_gherkin, :name => 'background_test_file', :directory => test_directory)
111
- end
112
-
113
-
114
- let(:test_directory) { CukeModeler::FileHelper.create_directory }
115
- let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
116
-
117
- #{BACKGROUND_KEYWORD}: Test background
118
- #{STEP_KEYWORD} a step"
119
- }
120
-
121
- let(:directory_model) { CukeModeler::Directory.new(test_directory) }
122
- let(:background_model) { directory_model.feature_files.first.feature.background }
123
-
124
-
125
- it 'can get its directory' do
126
- ancestor = background_model.get_ancestor(:directory)
127
-
128
- expect(ancestor).to equal(directory_model)
129
- end
130
-
131
- it 'can get its feature file' do
132
- ancestor = background_model.get_ancestor(:feature_file)
133
-
134
- expect(ancestor).to equal(directory_model.feature_files.first)
135
- end
136
-
137
- it 'can get its feature' do
138
- ancestor = background_model.get_ancestor(:feature)
139
-
140
- expect(ancestor).to equal(directory_model.feature_files.first.feature)
141
- end
142
-
143
- it 'returns nil if it does not have the requested type of ancestor' do
144
- ancestor = background_model.get_ancestor(:example)
145
-
146
- expect(ancestor).to be_nil
147
- end
148
-
149
- end
150
-
151
-
152
- describe 'model population' do
153
-
154
- context 'from source text' do
155
-
156
- let(:source_text) { "#{BACKGROUND_KEYWORD}:" }
157
- let(:background) { clazz.new(source_text) }
158
-
159
-
160
- it "models the background's keyword" do
161
- expect(background.keyword).to eq("#{BACKGROUND_KEYWORD}")
162
- end
163
-
164
- it "models the background's source line" do
165
- source_text = "#{FEATURE_KEYWORD}:
166
-
167
- #{BACKGROUND_KEYWORD}: foo
168
- #{STEP_KEYWORD} step"
169
- background = CukeModeler::Feature.new(source_text).background
170
-
171
- expect(background.source_line).to eq(3)
172
- end
173
-
174
- context 'a filled background' do
175
-
176
- let(:source_text) { "#{BACKGROUND_KEYWORD}: Background name
177
-
178
- Background description.
179
-
180
- Some more.
181
- Even more.
182
-
183
- #{STEP_KEYWORD} a step
184
- #{STEP_KEYWORD} another step" }
185
- let(:background) { clazz.new(source_text) }
186
-
187
-
188
- it "models the background's name" do
189
- expect(background.name).to eq('Background name')
190
- end
191
-
192
- it "models the background's description" do
193
- description = background.description.split("\n", -1)
194
-
195
- expect(description).to eq([' Background description.',
196
- '',
197
- 'Some more.',
198
- ' Even more.'])
199
- end
200
-
201
- it "models the background's steps" do
202
- step_names = background.steps.collect { |step| step.text }
203
-
204
- expect(step_names).to eq(['a step', 'another step'])
205
- end
206
-
207
- end
208
-
209
- context 'an empty background' do
210
-
211
- let(:source_text) { "#{BACKGROUND_KEYWORD}:" }
212
- let(:background) { clazz.new(source_text) }
213
-
214
-
215
- it "models the background's name" do
216
- expect(background.name).to eq('')
217
- end
218
-
219
- it "models the background's description" do
220
- expect(background.description).to eq('')
221
- end
222
-
223
- it "models the background's steps" do
224
- expect(background.steps).to eq([])
225
- end
226
-
227
- end
228
-
229
- end
230
-
231
- end
232
-
233
-
234
- describe 'comparison' do
235
-
236
- it 'is equal to a background with the same steps' do
237
- source = "#{BACKGROUND_KEYWORD}:
238
- #{STEP_KEYWORD} step 1
239
- #{STEP_KEYWORD} step 2"
240
- background_1 = clazz.new(source)
241
-
242
- source = "#{BACKGROUND_KEYWORD}:
243
- #{STEP_KEYWORD} step 1
244
- #{STEP_KEYWORD} step 2"
245
- background_2 = clazz.new(source)
246
-
247
- source = "#{BACKGROUND_KEYWORD}:
248
- #{STEP_KEYWORD} step 2
249
- #{STEP_KEYWORD} step 1"
250
- background_3 = clazz.new(source)
251
-
252
-
253
- expect(background_1).to eq(background_2)
254
- expect(background_1).to_not eq(background_3)
255
- end
256
-
257
- it 'is equal to a scenario with the same steps' do
258
- source = "#{BACKGROUND_KEYWORD}:
259
- #{STEP_KEYWORD} step 1
260
- #{STEP_KEYWORD} step 2"
261
- background = clazz.new(source)
262
-
263
- source = "#{SCENARIO_KEYWORD}:
264
- #{STEP_KEYWORD} step 1
265
- #{STEP_KEYWORD} step 2"
266
- scenario_1 = CukeModeler::Scenario.new(source)
267
-
268
- source = "#{SCENARIO_KEYWORD}:
269
- #{STEP_KEYWORD} step 2
270
- #{STEP_KEYWORD} step 1"
271
- scenario_2 = CukeModeler::Scenario.new(source)
272
-
273
-
274
- expect(background).to eq(scenario_1)
275
- expect(background).to_not eq(scenario_2)
276
- end
277
-
278
- it 'is equal to an outline with the same steps' do
279
- source = "#{BACKGROUND_KEYWORD}:
280
- #{STEP_KEYWORD} step 1
281
- #{STEP_KEYWORD} step 2"
282
- background = clazz.new(source)
283
-
284
- source = "#{OUTLINE_KEYWORD}:
285
- #{STEP_KEYWORD} step 1
286
- #{STEP_KEYWORD} step 2
287
- #{EXAMPLE_KEYWORD}:
288
- | param |
289
- | value |"
290
- outline_1 = CukeModeler::Outline.new(source)
291
-
292
- source = "#{OUTLINE_KEYWORD}:
293
- #{STEP_KEYWORD} step 2
294
- #{STEP_KEYWORD} step 1
295
- #{EXAMPLE_KEYWORD}:
296
- | param |
297
- | value |"
298
- outline_2 = CukeModeler::Outline.new(source)
299
-
300
-
301
- expect(background).to eq(outline_1)
302
- expect(background).to_not eq(outline_2)
303
- end
304
-
305
- end
306
-
307
-
308
- describe 'background output' do
309
-
310
- it 'can be remade from its own output' do
311
- source = "#{BACKGROUND_KEYWORD}: A background with everything it could have
312
-
313
- Including a description
314
- and then some.
315
-
316
- #{STEP_KEYWORD} a step
317
- | value |
318
- #{STEP_KEYWORD} another step
319
- \"\"\"
320
- some string
321
- \"\"\""
322
- background = clazz.new(source)
323
-
324
- background_output = background.to_s
325
- remade_background_output = clazz.new(background_output).to_s
326
-
327
- expect(remade_background_output).to eq(background_output)
328
- end
329
-
330
-
331
- context 'from source text' do
332
-
333
- it 'can output an empty background' do
334
- source = ["#{BACKGROUND_KEYWORD}:"]
335
- source = source.join("\n")
336
- background = clazz.new(source)
337
-
338
- background_output = background.to_s.split("\n", -1)
339
-
340
- expect(background_output).to eq(["#{BACKGROUND_KEYWORD}:"])
341
- end
342
-
343
- it 'can output a background that has a name' do
344
- source = ["#{BACKGROUND_KEYWORD}: test background"]
345
- source = source.join("\n")
346
- background = clazz.new(source)
347
-
348
- background_output = background.to_s.split("\n", -1)
349
-
350
- expect(background_output).to eq(["#{BACKGROUND_KEYWORD}: test background"])
351
- end
352
-
353
- it 'can output a background that has a description' do
354
- source = ["#{BACKGROUND_KEYWORD}:",
355
- 'Some description.',
356
- 'Some more description.']
357
- source = source.join("\n")
358
- background = clazz.new(source)
359
-
360
- background_output = background.to_s.split("\n", -1)
361
-
362
- expect(background_output).to eq(["#{BACKGROUND_KEYWORD}:",
363
- '',
364
- 'Some description.',
365
- 'Some more description.'])
366
- end
367
-
368
- it 'can output a background that has steps' do
369
- source = ["#{BACKGROUND_KEYWORD}:",
370
- "#{STEP_KEYWORD} a step",
371
- '|value|',
372
- "#{STEP_KEYWORD} another step",
373
- '"""',
374
- 'some string',
375
- '"""']
376
- source = source.join("\n")
377
- background = clazz.new(source)
378
-
379
- background_output = background.to_s.split("\n", -1)
380
-
381
- expect(background_output).to eq(["#{BACKGROUND_KEYWORD}:",
382
- " #{STEP_KEYWORD} a step",
383
- ' | value |',
384
- " #{STEP_KEYWORD} another step",
385
- ' """',
386
- ' some string',
387
- ' """'])
388
- end
389
-
390
- it 'can output a background that has everything' do
391
- source = ["#{BACKGROUND_KEYWORD}: A background with everything it could have",
392
- 'Including a description',
393
- 'and then some.',
394
- "#{STEP_KEYWORD} a step",
395
- '|value|',
396
- "#{STEP_KEYWORD} another step",
397
- '"""',
398
- 'some string',
399
- '"""']
400
- source = source.join("\n")
401
- background = clazz.new(source)
402
-
403
- background_output = background.to_s.split("\n", -1)
404
-
405
- expect(background_output).to eq(["#{BACKGROUND_KEYWORD}: A background with everything it could have",
406
- '',
407
- 'Including a description',
408
- 'and then some.',
409
- '',
410
- " #{STEP_KEYWORD} a step",
411
- ' | value |',
412
- " #{STEP_KEYWORD} another step",
413
- ' """',
414
- ' some string',
415
- ' """'])
416
- end
417
-
418
- end
419
-
420
-
421
- context 'from abstract instantiation' do
422
-
423
- let(:background) { clazz.new }
424
-
425
-
426
- it 'can output a background that has only steps' do
427
- background.steps = [CukeModeler::Step.new]
428
-
429
- expect { background.to_s }.to_not raise_error
430
- end
431
-
432
- end
433
-
434
- end
435
-
436
- end
437
-
438
- end
@@ -1,338 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/../../spec_helper"
2
-
3
-
4
- describe 'Cell, Integration' do
5
-
6
- let(:clazz) { CukeModeler::Cell }
7
-
8
-
9
- describe 'common behavior' do
10
-
11
- it_should_behave_like 'a model, integration'
12
-
13
- end
14
-
15
-
16
- describe 'unique behavior' do
17
-
18
- it 'can be instantiated with the minimum viable Gherkin' do
19
- source = ''
20
-
21
- expect { clazz.new(source) }.to_not raise_error
22
- end
23
-
24
- it 'can parse text that uses a non-default dialect' do
25
- original_dialect = CukeModeler::Parsing.dialect
26
- CukeModeler::Parsing.dialect = 'en-au'
27
-
28
- begin
29
- source_text = 'foo'
30
-
31
- expect { @model = clazz.new(source_text) }.to_not raise_error
32
-
33
- # Sanity check in case modeling failed in a non-explosive manner
34
- expect(@model.value).to eq('foo')
35
- ensure
36
- # Making sure that our changes don't escape a test and ruin the rest of the suite
37
- CukeModeler::Parsing.dialect = original_dialect
38
- end
39
- end
40
-
41
- it 'provides a descriptive filename when being parsed from stand alone text' do
42
- source = "not a \n cell"
43
-
44
- expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_cell\.feature'/)
45
- end
46
-
47
- describe 'parsing data' do
48
-
49
- it 'stores the original data generated by the parsing adapter', :if => gherkin?(6, 7, 8, 9) do
50
- cell = clazz.new('a cell')
51
- data = cell.parsing_data
52
-
53
- expect(data.keys).to match_array([:location, :value])
54
- expect(data[:value]).to eq('a cell')
55
- end
56
-
57
- it 'stores the original data generated by the parsing adapter', :if => gherkin?(4, 5) do
58
- cell = clazz.new('a cell')
59
- data = cell.parsing_data
60
-
61
- expect(data.keys).to match_array([:type, :location, :value])
62
- expect(data[:type]).to eq(:TableCell)
63
- end
64
-
65
- it 'stores the original data generated by the parsing adapter', :if => gherkin?(3) do
66
- cell = clazz.new("a cell")
67
- data = cell.parsing_data
68
-
69
- expect(data.keys).to match_array([:type, :location, :value])
70
- expect(data[:type]).to eq('TableCell')
71
- end
72
-
73
- it 'stores the original data generated by the parsing adapter', :if => gherkin?(2) do
74
- cell = clazz.new("a cell")
75
- data = cell.parsing_data
76
-
77
- # Cells did not exist as full fledged objects in the Gherkin2 parser
78
- expect(data).to eq('a cell')
79
- end
80
-
81
- end
82
-
83
- describe 'getting ancestors' do
84
-
85
- before(:each) do
86
- CukeModeler::FileHelper.create_feature_file(:text => source_gherkin, :name => 'cell_test_file', :directory => test_directory)
87
- end
88
-
89
-
90
- let(:test_directory) { CukeModeler::FileHelper.create_directory }
91
- let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
92
-
93
- #{SCENARIO_KEYWORD}: Test test
94
- #{STEP_KEYWORD} a step
95
- | a value |"
96
- }
97
-
98
- let(:directory_model) { CukeModeler::Directory.new(test_directory) }
99
- let(:cell_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block.rows.first.cells.first }
100
-
101
-
102
- it 'can get its directory' do
103
- ancestor = cell_model.get_ancestor(:directory)
104
-
105
- expect(ancestor).to equal(directory_model)
106
- end
107
-
108
- it 'can get its feature file' do
109
- ancestor = cell_model.get_ancestor(:feature_file)
110
-
111
- expect(ancestor).to equal(directory_model.feature_files.first)
112
- end
113
-
114
- it 'can get its feature' do
115
- ancestor = cell_model.get_ancestor(:feature)
116
-
117
- expect(ancestor).to equal(directory_model.feature_files.first.feature)
118
- end
119
-
120
- context 'a cell that is part of an outline' do
121
-
122
- let(:test_directory) { CukeModeler::FileHelper.create_directory }
123
- let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
124
-
125
- #{OUTLINE_KEYWORD}: Test outline
126
- #{STEP_KEYWORD} a step
127
- #{EXAMPLE_KEYWORD}:
128
- | param |
129
- | value |"
130
- }
131
-
132
- let(:directory_model) { CukeModeler::Directory.new(test_directory) }
133
- let(:cell_model) { directory_model.feature_files.first.feature.tests.first.examples.first.rows.first.cells.first }
134
-
135
-
136
- it 'can get its outline' do
137
- ancestor = cell_model.get_ancestor(:outline)
138
-
139
- expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
140
- end
141
-
142
- it 'can get its example' do
143
- ancestor = cell_model.get_ancestor(:example)
144
-
145
- expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.examples.first)
146
- end
147
-
148
- it 'can get its row' do
149
- ancestor = cell_model.get_ancestor(:row)
150
-
151
- expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.examples.first.rows.first)
152
- end
153
-
154
- end
155
-
156
-
157
- context 'a cell that is part of a scenario' do
158
-
159
- let(:test_directory) { CukeModeler::FileHelper.create_directory }
160
- let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
161
-
162
- #{SCENARIO_KEYWORD}: Test test
163
- #{STEP_KEYWORD} a step:
164
- | a | table |"
165
- }
166
-
167
- let(:directory_model) { CukeModeler::Directory.new(test_directory) }
168
- let(:cell_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block.rows.first.cells.first }
169
-
170
-
171
- it 'can get its scenario' do
172
- ancestor = cell_model.get_ancestor(:scenario)
173
-
174
- expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
175
- end
176
-
177
- end
178
-
179
- context 'a cell that is part of a background' do
180
-
181
- let(:test_directory) { CukeModeler::FileHelper.create_directory }
182
- let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
183
-
184
- #{BACKGROUND_KEYWORD}: Test background
185
- #{STEP_KEYWORD} a step:
186
- | a | table |"
187
- }
188
-
189
- let(:directory_model) { CukeModeler::Directory.new(test_directory) }
190
- let(:cell_model) { directory_model.feature_files.first.feature.background.steps.first.block.rows.first.cells.first }
191
-
192
-
193
- it 'can get its background' do
194
- ancestor = cell_model.get_ancestor(:background)
195
-
196
- expect(ancestor).to equal(directory_model.feature_files.first.feature.background)
197
- end
198
-
199
- end
200
-
201
- context 'a cell that is part of a step' do
202
-
203
- let(:test_directory) { CukeModeler::FileHelper.create_directory }
204
- let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
205
-
206
- #{SCENARIO_KEYWORD}: Test test
207
- #{STEP_KEYWORD} a step:
208
- | a | table |"
209
- }
210
-
211
- let(:directory_model) { CukeModeler::Directory.new(test_directory) }
212
- let(:cell_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block.rows.first.cells.first }
213
-
214
-
215
- it 'can get its step' do
216
- ancestor = cell_model.get_ancestor(:step)
217
-
218
- expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.steps.first)
219
- end
220
-
221
- it 'can get its table' do
222
- ancestor = cell_model.get_ancestor(:table)
223
-
224
- expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.steps.first.block)
225
- end
226
-
227
- it 'can get its row' do
228
- ancestor = cell_model.get_ancestor(:row)
229
-
230
- expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.steps.first.block.rows.first)
231
- end
232
-
233
- end
234
-
235
- it 'returns nil if it does not have the requested type of ancestor' do
236
- ancestor = cell_model.get_ancestor(:example)
237
-
238
- expect(ancestor).to be_nil
239
- end
240
-
241
- end
242
-
243
-
244
- describe 'model population' do
245
-
246
- context 'from source text' do
247
-
248
- let(:source_text) { 'a cell' }
249
- let(:cell) { clazz.new(source_text) }
250
-
251
-
252
- it "models the cell's value" do
253
- expect(cell.value).to eq('a cell')
254
- end
255
-
256
- it "models the cell's source line" do
257
- source_text = "#{FEATURE_KEYWORD}:
258
-
259
- #{SCENARIO_KEYWORD}:
260
- #{STEP_KEYWORD} a step
261
- | value |"
262
- cell = CukeModeler::Feature.new(source_text).tests.first.steps.first.block.rows.first.cells.first
263
-
264
- expect(cell.source_line).to eq(5)
265
- end
266
-
267
- end
268
-
269
- end
270
-
271
-
272
- describe 'cell output' do
273
-
274
- it 'can be remade from its own output' do
275
- source = 'a \\\\ complex \| cell'
276
- cell = clazz.new(source)
277
-
278
- cell_output = cell.to_s
279
- remade_cell_output = clazz.new(cell_output).to_s
280
-
281
- expect(remade_cell_output).to eq(cell_output)
282
- end
283
-
284
-
285
- context 'from source text' do
286
-
287
- it 'can output a cell' do
288
- source = 'a cell'
289
- cell = clazz.new(source)
290
-
291
- expect(cell.to_s).to eq('a cell')
292
- end
293
-
294
- # Because vertical bars mark the beginning and end of a cell, any vertical bars inside
295
- # of the cell (which would have had to have been escaped to get inside of the cell in
296
- # the first place) will be escaped when outputted so as to retain the quality of being
297
- # able to use the output directly as Gherkin.
298
-
299
- it 'can output a cell that has vertical bars in it' do
300
- source = 'cell with a \| in it'
301
- cell = clazz.new(source)
302
-
303
- cell_output = cell.to_s
304
-
305
- expect(cell_output).to eq('cell with a \| in it')
306
- end
307
-
308
- # Because backslashes are used to escape special characters, any backslashes inside
309
- # of the cell (which would have had to have been escaped to get inside of the cell in
310
- # the first place) will be escaped when outputted so as to retain the quality of being
311
- # able to use the output directly as Gherkin.
312
-
313
- it 'can output a cell that has backslashes in it' do
314
- source = 'cell with a \\\\ in it'
315
- cell = clazz.new(source)
316
-
317
- cell_output = cell.to_s
318
-
319
- expect(cell_output).to eq('cell with a \\\\ in it')
320
- end
321
-
322
- # Depending on the order in which special characters are escaped, extra backslashes might occur.
323
- it 'can output a cell that has several kinds of special characters in it' do
324
- source = 'cell with a \\\\ and \| in it'
325
- cell = clazz.new(source)
326
-
327
- cell_output = cell.to_s
328
-
329
- expect(cell_output).to eq('cell with a \\\\ and \| in it')
330
- end
331
-
332
- end
333
-
334
- end
335
-
336
- end
337
-
338
- end