cuke_modeler 2.0.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +59 -2
  3. data/README.md +14 -16
  4. data/cuke_modeler.gemspec +12 -9
  5. data/lib/cuke_modeler.rb +1 -0
  6. data/lib/cuke_modeler/adapters/gherkin_10_adapter.rb +12 -0
  7. data/lib/cuke_modeler/adapters/gherkin_11_adapter.rb +12 -0
  8. data/lib/cuke_modeler/adapters/gherkin_12_adapter.rb +12 -0
  9. data/lib/cuke_modeler/adapters/gherkin_13_adapter.rb +12 -0
  10. data/lib/cuke_modeler/adapters/gherkin_14_adapter.rb +12 -0
  11. data/lib/cuke_modeler/adapters/gherkin_15_adapter.rb +12 -0
  12. data/lib/cuke_modeler/adapters/{gherkin_6_adapter.rb → gherkin_9_adapter.rb} +104 -69
  13. data/lib/cuke_modeler/containing.rb +15 -5
  14. data/lib/cuke_modeler/models/background.rb +1 -1
  15. data/lib/cuke_modeler/models/cell.rb +1 -1
  16. data/lib/cuke_modeler/models/comment.rb +1 -1
  17. data/lib/cuke_modeler/models/directory.rb +2 -2
  18. data/lib/cuke_modeler/models/doc_string.rb +1 -1
  19. data/lib/cuke_modeler/models/example.rb +1 -1
  20. data/lib/cuke_modeler/models/feature.rb +16 -5
  21. data/lib/cuke_modeler/models/feature_file.rb +2 -2
  22. data/lib/cuke_modeler/models/outline.rb +1 -1
  23. data/lib/cuke_modeler/models/row.rb +1 -1
  24. data/lib/cuke_modeler/models/rule.rb +99 -0
  25. data/lib/cuke_modeler/models/scenario.rb +1 -1
  26. data/lib/cuke_modeler/models/step.rb +1 -1
  27. data/lib/cuke_modeler/models/table.rb +1 -1
  28. data/lib/cuke_modeler/models/tag.rb +1 -1
  29. data/lib/cuke_modeler/parsing.rb +89 -110
  30. data/lib/cuke_modeler/version.rb +1 -1
  31. data/testing/cucumber/features/modeling/feature_modeling.feature +28 -7
  32. data/testing/cucumber/features/modeling/feature_output.feature +45 -23
  33. data/testing/cucumber/features/modeling/rule_modeling.feature +108 -0
  34. data/testing/cucumber/features/modeling/rule_output.feature +111 -0
  35. metadata +39 -140
  36. data/.gitignore +0 -18
  37. data/.simplecov +0 -7
  38. data/.travis.yml +0 -63
  39. data/Gemfile +0 -37
  40. data/Rakefile +0 -73
  41. data/appveyor.yml +0 -61
  42. data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +0 -274
  43. data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +0 -297
  44. data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +0 -309
  45. data/testing/cucumber/step_definitions/action_steps.rb +0 -13
  46. data/testing/cucumber/step_definitions/background_steps.rb +0 -1
  47. data/testing/cucumber/step_definitions/directory_steps.rb +0 -6
  48. data/testing/cucumber/step_definitions/doc_string_steps.rb +0 -1
  49. data/testing/cucumber/step_definitions/feature_file_steps.rb +0 -16
  50. data/testing/cucumber/step_definitions/feature_steps.rb +0 -7
  51. data/testing/cucumber/step_definitions/modeling_steps.rb +0 -49
  52. data/testing/cucumber/step_definitions/setup_steps.rb +0 -32
  53. data/testing/cucumber/step_definitions/step_steps.rb +0 -3
  54. data/testing/cucumber/step_definitions/table_steps.rb +0 -1
  55. data/testing/cucumber/step_definitions/tag_steps.rb +0 -3
  56. data/testing/cucumber/step_definitions/verification_steps.rb +0 -181
  57. data/testing/cucumber/support/env.rb +0 -30
  58. data/testing/dialect_helper.rb +0 -48
  59. data/testing/file_helper.rb +0 -47
  60. data/testing/gemfiles/gherkin2.gemfile +0 -33
  61. data/testing/gemfiles/gherkin3.gemfile +0 -26
  62. data/testing/gemfiles/gherkin4.gemfile +0 -27
  63. data/testing/gemfiles/gherkin5.gemfile +0 -27
  64. data/testing/gemfiles/gherkin6.gemfile +0 -10
  65. data/testing/rspec/spec/integration/adapters/gherkin_2_adapter_spec.rb +0 -166
  66. data/testing/rspec/spec/integration/adapters/gherkin_3_adapter_spec.rb +0 -166
  67. data/testing/rspec/spec/integration/adapters/gherkin_4_adapter_spec.rb +0 -165
  68. data/testing/rspec/spec/integration/adapters/gherkin_6_adapter_spec.rb +0 -166
  69. data/testing/rspec/spec/integration/models/background_integration_spec.rb +0 -442
  70. data/testing/rspec/spec/integration/models/cell_integration_spec.rb +0 -335
  71. data/testing/rspec/spec/integration/models/comment_integration_spec.rb +0 -177
  72. data/testing/rspec/spec/integration/models/directory_integration_spec.rb +0 -218
  73. data/testing/rspec/spec/integration/models/doc_string_integration_spec.rb +0 -402
  74. data/testing/rspec/spec/integration/models/example_integration_spec.rb +0 -741
  75. data/testing/rspec/spec/integration/models/feature_file_integration_spec.rb +0 -272
  76. data/testing/rspec/spec/integration/models/feature_integration_spec.rb +0 -650
  77. data/testing/rspec/spec/integration/models/model_integration_spec.rb +0 -15
  78. data/testing/rspec/spec/integration/models/outline_integration_spec.rb +0 -624
  79. data/testing/rspec/spec/integration/models/row_integration_spec.rb +0 -291
  80. data/testing/rspec/spec/integration/models/scenario_integration_spec.rb +0 -479
  81. data/testing/rspec/spec/integration/models/step_integration_spec.rb +0 -569
  82. data/testing/rspec/spec/integration/models/table_integration_spec.rb +0 -337
  83. data/testing/rspec/spec/integration/models/tag_integration_spec.rb +0 -259
  84. data/testing/rspec/spec/integration/nested_integration_spec.rb +0 -91
  85. data/testing/rspec/spec/integration/parsing_integration_spec.rb +0 -122
  86. data/testing/rspec/spec/integration/shared/models_integration_specs.rb +0 -18
  87. data/testing/rspec/spec/spec_helper.rb +0 -136
  88. data/testing/rspec/spec/unit/cuke_modeler_unit_spec.rb +0 -25
  89. data/testing/rspec/spec/unit/described_unit_spec.rb +0 -23
  90. data/testing/rspec/spec/unit/models/background_unit_spec.rb +0 -83
  91. data/testing/rspec/spec/unit/models/cell_unit_spec.rb +0 -68
  92. data/testing/rspec/spec/unit/models/comment_unit_spec.rb +0 -68
  93. data/testing/rspec/spec/unit/models/directory_unit_spec.rb +0 -127
  94. data/testing/rspec/spec/unit/models/doc_string_unit_spec.rb +0 -100
  95. data/testing/rspec/spec/unit/models/example_unit_spec.rb +0 -133
  96. data/testing/rspec/spec/unit/models/feature_file_unit_spec.rb +0 -125
  97. data/testing/rspec/spec/unit/models/feature_unit_spec.rb +0 -157
  98. data/testing/rspec/spec/unit/models/model_unit_spec.rb +0 -15
  99. data/testing/rspec/spec/unit/models/outline_unit_spec.rb +0 -117
  100. data/testing/rspec/spec/unit/models/row_unit_spec.rb +0 -68
  101. data/testing/rspec/spec/unit/models/scenario_unit_spec.rb +0 -86
  102. data/testing/rspec/spec/unit/models/step_unit_spec.rb +0 -109
  103. data/testing/rspec/spec/unit/models/table_unit_spec.rb +0 -77
  104. data/testing/rspec/spec/unit/models/tag_unit_spec.rb +0 -68
  105. data/testing/rspec/spec/unit/named_unit_spec.rb +0 -23
  106. data/testing/rspec/spec/unit/nested_unit_spec.rb +0 -43
  107. data/testing/rspec/spec/unit/parsed_unit_spec.rb +0 -27
  108. data/testing/rspec/spec/unit/parsing_unit_spec.rb +0 -54
  109. data/testing/rspec/spec/unit/shared/bare_bones_models_unit_specs.rb +0 -14
  110. data/testing/rspec/spec/unit/shared/containing_models_unit_specs.rb +0 -127
  111. data/testing/rspec/spec/unit/shared/described_models_unit_specs.rb +0 -38
  112. data/testing/rspec/spec/unit/shared/keyworded_models_unit_specs.rb +0 -58
  113. data/testing/rspec/spec/unit/shared/models_unit_specs.rb +0 -15
  114. data/testing/rspec/spec/unit/shared/named_models_unit_specs.rb +0 -39
  115. data/testing/rspec/spec/unit/shared/nested_models_unit_specs.rb +0 -51
  116. data/testing/rspec/spec/unit/shared/parsed_models_unit_specs.rb +0 -39
  117. data/testing/rspec/spec/unit/shared/prepopulated_models_unit_specs.rb +0 -18
  118. data/testing/rspec/spec/unit/shared/sourced_models_unit_specs.rb +0 -39
  119. data/testing/rspec/spec/unit/shared/stepped_models_unit_specs.rb +0 -46
  120. data/testing/rspec/spec/unit/shared/stringifiable_models_unit_specs.rb +0 -18
  121. data/testing/rspec/spec/unit/shared/tagged_models_unit_specs.rb +0 -72
  122. data/testing/rspec/spec/unit/sourceable_unit_spec.rb +0 -27
  123. data/testing/rspec/spec/unit/stepped_unit_spec.rb +0 -23
  124. data/testing/rspec/spec/unit/taggable_unit_spec.rb +0 -69
  125. data/testing/test_languages.json +0 -45
  126. data/todo.txt +0 -25
@@ -1,569 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/../../spec_helper"
2
-
3
-
4
- describe 'Step, Integration' do
5
-
6
- let(:clazz) { CukeModeler::Step }
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 = "#{STEP_KEYWORD} a step"
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 = "Y'know a step"
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.keyword).to eq("Y'know")
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
- it 'provides a descriptive filename when being parsed from stand alone text' do
41
- source = "bad step text\n And a step\n @foo"
42
-
43
- expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_step\.feature'/)
44
- end
45
-
46
- it 'stores the original data generated by the parsing adapter (with a table)', :gherkin6 => true do
47
- step = clazz.new("#{STEP_KEYWORD} test step\n|table|")
48
- data = step.parsing_data
49
-
50
- expect(data.keys).to match_array([:location, :keyword, :text, :data_table, :doc_string])
51
- expect(data[:text]).to eq('test step')
52
- end
53
-
54
- it 'stores the original data generated by the parsing adapter (with a doc string)', :gherkin6 => true do
55
- step = clazz.new("#{STEP_KEYWORD} test step\n\"\"\"\na doc string\n\"\"\"")
56
- data = step.parsing_data
57
-
58
- expect(data.keys).to match_array([:location, :keyword, :text, :data_table, :doc_string])
59
- expect(data[:text]).to eq('test step')
60
- end
61
-
62
- it 'stores the original data generated by the parsing adapter (with a table)', :gherkin4_5 => true do
63
- step = clazz.new("#{STEP_KEYWORD} test step\n|table|")
64
- data = step.parsing_data
65
-
66
- expect(data.keys).to match_array([:type, :location, :keyword, :text, :argument])
67
- expect(data[:type]).to eq(:Step)
68
- end
69
-
70
- it 'stores the original data generated by the parsing adapter (with a doc string)', :gherkin4_5 => true do
71
- step = clazz.new("#{STEP_KEYWORD} test step\n\"\"\"\na doc string\n\"\"\"")
72
- data = step.parsing_data
73
-
74
- expect(data.keys).to match_array([:type, :location, :keyword, :text, :argument])
75
- expect(data[:type]).to eq(:Step)
76
- end
77
-
78
- it 'stores the original data generated by the parsing adapter (with a table)', :gherkin3 => true do
79
- step = clazz.new("#{STEP_KEYWORD} test step\n|table|")
80
- data = step.parsing_data
81
-
82
- expect(data.keys).to match_array([:type, :location, :keyword, :text, :argument])
83
- expect(data[:type]).to eq(:Step)
84
- end
85
-
86
- it 'stores the original data generated by the parsing adapter (with a doc string)', :gherkin3 => true do
87
- step = clazz.new("#{STEP_KEYWORD} test step\n\"\"\"\na doc string\n\"\"\"")
88
- data = step.parsing_data
89
-
90
- expect(data.keys).to match_array([:type, :location, :keyword, :text, :argument])
91
- expect(data[:type]).to eq(:Step)
92
- end
93
-
94
- it 'stores the original data generated by the parsing adapter (with a table)', :gherkin2 => true do
95
- step = clazz.new("#{STEP_KEYWORD} test step\n|table|")
96
- data = step.parsing_data
97
-
98
- expect(data.keys).to match_array(['keyword', 'name', 'line', 'rows'])
99
- expect(data['keyword']).to eq("#{STEP_KEYWORD} ")
100
- end
101
-
102
- it 'stores the original data generated by the parsing adapter (with a doc string)', :gherkin2 => true do
103
- step = clazz.new("#{STEP_KEYWORD} test step\n\"\"\"\na doc string\n\"\"\"")
104
- data = step.parsing_data
105
-
106
- expect(data.keys).to match_array(['keyword', 'name', 'line', 'doc_string'])
107
- expect(data['keyword']).to eq("#{STEP_KEYWORD} ")
108
- end
109
-
110
- describe 'model population' do
111
-
112
- context 'from source text' do
113
-
114
- let(:source_text) { "#{STEP_KEYWORD} a step" }
115
- let(:step) { clazz.new(source_text) }
116
-
117
-
118
- it "models the step's keyword" do
119
- expect(step.keyword).to eq("#{STEP_KEYWORD}")
120
- end
121
-
122
- it "models the step's text" do
123
- expect(step.text).to eq('a step')
124
- end
125
-
126
- it "models the step's source line" do
127
- source_text = "#{FEATURE_KEYWORD}:
128
-
129
- #{SCENARIO_KEYWORD}: foo
130
- #{STEP_KEYWORD} step"
131
- step = CukeModeler::Feature.new(source_text).tests.first.steps.first
132
-
133
- expect(step.source_line).to eq(4)
134
- end
135
-
136
-
137
- context 'with no block' do
138
-
139
- let(:source_text) { "#{STEP_KEYWORD} a step" }
140
- let(:step) { clazz.new(source_text) }
141
-
142
-
143
- it "models the step's block" do
144
- expect(step.block).to be_nil
145
- end
146
-
147
- end
148
-
149
- context 'a step with a table' do
150
-
151
- let(:source_text) { "#{STEP_KEYWORD} a step
152
- | value 1 |
153
- | value 2 |" }
154
- let(:step) { clazz.new(source_text) }
155
-
156
-
157
- it "models the step's table" do
158
- table_cell_values = step.block.rows.collect { |row| row.cells.collect { |cell| cell.value } }
159
-
160
- expect(table_cell_values).to eq([['value 1'], ['value 2']])
161
- end
162
-
163
- end
164
-
165
- context 'a step with a doc string' do
166
-
167
- let(:source_text) { "#{STEP_KEYWORD} a step
168
- \"\"\"
169
- some text
170
- \"\"\"" }
171
- let(:step) { clazz.new(source_text) }
172
-
173
-
174
- it "models the step's doc string" do
175
- doc_string = step.block
176
-
177
- expect(doc_string.content).to eq('some text')
178
- end
179
-
180
- end
181
-
182
- end
183
-
184
- end
185
-
186
-
187
- it 'properly sets its child models' do
188
- source_1 = "#{STEP_KEYWORD} a step
189
- \"\"\"
190
- a doc string
191
- \"\"\""
192
- source_2 = "#{STEP_KEYWORD} a step
193
- | a block|"
194
-
195
- step_1 = clazz.new(source_1)
196
- step_2 = clazz.new(source_2)
197
-
198
-
199
- doc_string = step_1.block
200
- table = step_2.block
201
-
202
- expect(doc_string.parent_model).to equal(step_1)
203
- expect(table.parent_model).to equal(step_2)
204
- end
205
-
206
-
207
- describe 'step comparison' do
208
-
209
- context 'a step that has text' do
210
-
211
- let(:step_text) { "#{STEP_KEYWORD} a step" }
212
- let(:base_step) { clazz.new(step_text) }
213
-
214
- context 'compared to a step that has the same text' do
215
-
216
- let(:compared_step) { clazz.new(step_text) }
217
-
218
- it 'considers them to be equal' do
219
- assert_bidirectional_equality(base_step, compared_step)
220
- end
221
-
222
- end
223
-
224
- context 'compared to a step that has different text' do
225
-
226
- let(:compared_step) { clazz.new(step_text + ' plus some more') }
227
-
228
- it 'considers them to not be equal' do
229
- assert_bidirectional_inequality(base_step, compared_step)
230
- end
231
-
232
- end
233
-
234
- context 'compared to a step that has a table' do
235
-
236
- let(:compared_step) { clazz.new(step_text + "\n | foo |") }
237
-
238
- it 'considers them to not be equal' do
239
- assert_bidirectional_inequality(base_step, compared_step)
240
- end
241
-
242
- end
243
-
244
- context 'compared to a step that has a doc string' do
245
-
246
- let(:compared_step) { clazz.new(step_text + "\n \"\"\"\n foo\n\"\"\"") }
247
-
248
- it 'considers them to not be equal' do
249
- assert_bidirectional_inequality(base_step, compared_step)
250
- end
251
-
252
- end
253
-
254
-
255
- context 'and has table' do
256
-
257
- let(:step_text) { "#{STEP_KEYWORD} a step\n | foo |" }
258
- let(:base_step) { clazz.new(step_text) }
259
-
260
- context 'compared to a step that has the same table' do
261
-
262
- let(:compared_step) { clazz.new(step_text) }
263
-
264
- it 'considers them to be equal' do
265
- assert_bidirectional_equality(base_step, compared_step)
266
- end
267
-
268
- end
269
-
270
- context 'compared to a step that has a different table' do
271
-
272
- let(:compared_step) { clazz.new(step_text + "\n | a different table |") }
273
-
274
- it 'considers them to not be equal' do
275
- assert_bidirectional_inequality(base_step, compared_step)
276
- end
277
-
278
- end
279
-
280
- end
281
-
282
-
283
- context 'and has a doc string' do
284
-
285
- let(:content) { 'foo' }
286
- let(:base_step) { clazz.new("#{step_text}\n\"\"\"\n#{content}\n\"\"\"") }
287
-
288
- context 'compared to a step that has the same doc string' do
289
-
290
- let(:compared_step) { clazz.new("#{step_text}\n\"\"\"\n#{content}\n\"\"\"") }
291
-
292
- it 'considers them to be equal' do
293
- assert_bidirectional_equality(base_step, compared_step)
294
- end
295
-
296
- end
297
-
298
- context 'compared to a step that has a different doc string' do
299
-
300
- let(:compared_step) { clazz.new("#{step_text}\n\"\"\"\n#{content + 'different'}\n\"\"\"") }
301
-
302
- it 'considers them to not be equal' do
303
- assert_bidirectional_inequality(base_step, compared_step)
304
- end
305
-
306
- end
307
-
308
- context 'and has a content type' do
309
-
310
- let(:content_type) { 'foo' }
311
- let(:base_step) { clazz.new("#{step_text}\n\"\"\" #{content_type}\n#{content}\n\"\"\"") }
312
-
313
-
314
- context 'compared to a step that has the same content type' do
315
-
316
- let(:compared_step) { clazz.new("#{step_text}\n\"\"\" #{content_type}\n#{content}\n\"\"\"") }
317
-
318
- it 'considers them to be equal' do
319
- assert_bidirectional_equality(base_step, compared_step)
320
- end
321
-
322
- end
323
-
324
- context 'compared to a step that has a different content type' do
325
-
326
- let(:compared_step) { clazz.new("#{step_text}\n\"\"\" different #{content_type}\n#{content}\n\"\"\"") }
327
-
328
- it 'considers them to not be equal' do
329
- assert_bidirectional_inequality(base_step, compared_step)
330
- end
331
-
332
- end
333
-
334
- end
335
-
336
- end
337
-
338
- end
339
-
340
- it 'ignores steps keywords when comparing steps' do
341
- source_1 = "#{GIVEN_KEYWORD} a step"
342
- source_2 = "#{THEN_KEYWORD} a step"
343
-
344
- step_1 = clazz.new(source_1)
345
- step_2 = clazz.new(source_2)
346
-
347
-
348
- expect(step_1).to eq(step_2)
349
- end
350
-
351
- end
352
-
353
-
354
- describe 'getting ancestors' do
355
-
356
- before(:each) do
357
- CukeModeler::FileHelper.create_feature_file(:text => source_gherkin, :name => 'step_test_file', :directory => test_directory)
358
- end
359
-
360
-
361
- let(:test_directory) { CukeModeler::FileHelper.create_directory }
362
- let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
363
-
364
- #{SCENARIO_KEYWORD}: Test test
365
- #{STEP_KEYWORD} a step:"
366
- }
367
-
368
- let(:directory_model) { CukeModeler::Directory.new(test_directory) }
369
- let(:step_model) { directory_model.feature_files.first.feature.tests.first.steps.first }
370
-
371
-
372
- it 'can get its directory' do
373
- ancestor = step_model.get_ancestor(:directory)
374
-
375
- expect(ancestor).to equal(directory_model)
376
- end
377
-
378
- it 'can get its feature file' do
379
- ancestor = step_model.get_ancestor(:feature_file)
380
-
381
- expect(ancestor).to equal(directory_model.feature_files.first)
382
- end
383
-
384
- it 'can get its feature' do
385
- ancestor = step_model.get_ancestor(:feature)
386
-
387
- expect(ancestor).to equal(directory_model.feature_files.first.feature)
388
- end
389
-
390
-
391
- context 'a step that is part of a scenario' do
392
-
393
- let(:test_directory) { CukeModeler::FileHelper.create_directory }
394
- let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
395
-
396
- #{SCENARIO_KEYWORD}: Test scenario
397
- #{STEP_KEYWORD} a step"
398
- }
399
-
400
- let(:directory_model) { CukeModeler::Directory.new(test_directory) }
401
- let(:step_model) { directory_model.feature_files.first.feature.tests.first.steps.first }
402
-
403
-
404
- it 'can get its scenario' do
405
- ancestor = step_model.get_ancestor(:scenario)
406
-
407
- expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
408
- end
409
-
410
- end
411
-
412
- context 'a step that is part of an outline' do
413
-
414
- let(:test_directory) { CukeModeler::FileHelper.create_directory }
415
- let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
416
-
417
- #{OUTLINE_KEYWORD}: Test outline
418
- #{STEP_KEYWORD} a step
419
- #{EXAMPLE_KEYWORD}:
420
- | param |
421
- | value |"
422
- }
423
-
424
- let(:directory_model) { CukeModeler::Directory.new(test_directory) }
425
- let(:step_model) { directory_model.feature_files.first.feature.tests.first.steps.first }
426
-
427
-
428
- it 'can get its outline' do
429
- ancestor = step_model.get_ancestor(:outline)
430
-
431
- expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
432
- end
433
-
434
- end
435
-
436
- context 'a step that is part of a background' do
437
-
438
- let(:test_directory) { CukeModeler::FileHelper.create_directory }
439
- let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
440
-
441
- #{BACKGROUND_KEYWORD}: Test background
442
- #{STEP_KEYWORD} a step"
443
- }
444
-
445
- let(:directory_model) { CukeModeler::Directory.new(test_directory) }
446
- let(:step_model) { directory_model.feature_files.first.feature.background.steps.first }
447
-
448
-
449
- it 'can get its background' do
450
- ancestor = step_model.get_ancestor(:background)
451
-
452
- expect(ancestor).to equal(directory_model.feature_files.first.feature.background)
453
- end
454
-
455
- end
456
-
457
- it 'returns nil if it does not have the requested type of ancestor' do
458
- ancestor = step_model.get_ancestor(:example)
459
-
460
- expect(ancestor).to be_nil
461
- end
462
-
463
- end
464
-
465
-
466
- describe 'step output' do
467
-
468
- context 'from source text' do
469
-
470
- context 'with no block' do
471
-
472
- let(:source_text) { ["#{STEP_KEYWORD} a step"].join("\n") }
473
- let(:step) { clazz.new(source_text) }
474
-
475
- it 'can output a step' do
476
- step_output = step.to_s.split("\n", -1)
477
-
478
- expect(step_output).to eq(["#{STEP_KEYWORD} a step"])
479
- end
480
-
481
- it 'can be remade from its own output' do
482
- step_output = step.to_s
483
- remade_step_output = clazz.new(step_output).to_s
484
-
485
- expect(remade_step_output).to eq(step_output)
486
- end
487
-
488
- end
489
-
490
- context 'a step with a table' do
491
-
492
- let(:source_text) { ["#{STEP_KEYWORD} a step",
493
- ' | value1 | value2 |',
494
- ' | value3 | value4 |'].join("\n") }
495
- let(:step) { clazz.new(source_text) }
496
-
497
-
498
- it 'can output a step that has a table' do
499
- step_output = step.to_s.split("\n", -1)
500
-
501
- expect(step_output).to eq(["#{STEP_KEYWORD} a step",
502
- ' | value1 | value2 |',
503
- ' | value3 | value4 |'])
504
-
505
- end
506
-
507
- it 'can be remade from its own output' do
508
- step_output = step.to_s
509
- remade_step_output = clazz.new(step_output).to_s
510
-
511
- expect(remade_step_output).to eq(step_output)
512
- end
513
-
514
- end
515
-
516
- context 'a step with a doc string' do
517
-
518
- let(:source_text) { ["#{STEP_KEYWORD} a step",
519
- ' """',
520
- ' some text',
521
- ' """'].join("\n") }
522
- let(:step) { clazz.new(source_text) }
523
-
524
-
525
- it 'can output a step that has a doc string' do
526
- step_output = step.to_s.split("\n", -1)
527
-
528
- expect(step_output).to eq(["#{STEP_KEYWORD} a step",
529
- ' """',
530
- ' some text',
531
- ' """'])
532
- end
533
-
534
- it 'can be remade from its own output' do
535
- step_output = step.to_s
536
- remade_step_output = clazz.new(step_output).to_s
537
-
538
- expect(remade_step_output).to eq(step_output)
539
- end
540
-
541
- end
542
-
543
- end
544
-
545
-
546
- context 'from abstract instantiation' do
547
-
548
- let(:step) { clazz.new }
549
-
550
-
551
- it 'can output a step that has only a table' do
552
- step.block = CukeModeler::Table.new
553
-
554
- expect { step.to_s }.to_not raise_error
555
- end
556
-
557
- it 'can output a step that has only a doc string' do
558
- step.block = CukeModeler::DocString.new
559
-
560
- expect { step.to_s }.to_not raise_error
561
- end
562
-
563
- end
564
-
565
- end
566
-
567
- end
568
-
569
- end