cuke_modeler 2.1.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -1
  3. data/README.md +11 -14
  4. data/cuke_modeler.gemspec +12 -9
  5. data/lib/cuke_modeler/adapters/gherkin_10_adapter.rb +12 -0
  6. data/lib/cuke_modeler/adapters/gherkin_11_adapter.rb +12 -0
  7. data/lib/cuke_modeler/adapters/gherkin_12_adapter.rb +12 -0
  8. data/lib/cuke_modeler/adapters/gherkin_13_adapter.rb +12 -0
  9. data/lib/cuke_modeler/adapters/gherkin_9_adapter.rb +313 -5
  10. data/lib/cuke_modeler/models/background.rb +1 -1
  11. data/lib/cuke_modeler/models/cell.rb +1 -1
  12. data/lib/cuke_modeler/models/comment.rb +1 -1
  13. data/lib/cuke_modeler/models/directory.rb +2 -2
  14. data/lib/cuke_modeler/models/doc_string.rb +1 -1
  15. data/lib/cuke_modeler/models/example.rb +1 -1
  16. data/lib/cuke_modeler/models/feature.rb +1 -1
  17. data/lib/cuke_modeler/models/feature_file.rb +2 -2
  18. data/lib/cuke_modeler/models/outline.rb +1 -1
  19. data/lib/cuke_modeler/models/row.rb +1 -1
  20. data/lib/cuke_modeler/models/scenario.rb +1 -1
  21. data/lib/cuke_modeler/models/step.rb +1 -1
  22. data/lib/cuke_modeler/models/table.rb +1 -1
  23. data/lib/cuke_modeler/models/tag.rb +1 -1
  24. data/lib/cuke_modeler/parsing.rb +29 -58
  25. data/lib/cuke_modeler/version.rb +1 -1
  26. metadata +33 -151
  27. data/.gitignore +0 -18
  28. data/.simplecov +0 -7
  29. data/.travis.yml +0 -81
  30. data/Gemfile +0 -44
  31. data/Rakefile +0 -73
  32. data/appveyor.yml +0 -88
  33. data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +0 -274
  34. data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +0 -297
  35. data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +0 -309
  36. data/lib/cuke_modeler/adapters/gherkin_5_adapter.rb +0 -12
  37. data/lib/cuke_modeler/adapters/gherkin_6_adapter.rb +0 -310
  38. data/lib/cuke_modeler/adapters/gherkin_7_adapter.rb +0 -307
  39. data/lib/cuke_modeler/adapters/gherkin_8_adapter.rb +0 -12
  40. data/testing/cucumber/step_definitions/action_steps.rb +0 -13
  41. data/testing/cucumber/step_definitions/background_steps.rb +0 -1
  42. data/testing/cucumber/step_definitions/directory_steps.rb +0 -6
  43. data/testing/cucumber/step_definitions/doc_string_steps.rb +0 -1
  44. data/testing/cucumber/step_definitions/feature_file_steps.rb +0 -16
  45. data/testing/cucumber/step_definitions/feature_steps.rb +0 -7
  46. data/testing/cucumber/step_definitions/modeling_steps.rb +0 -49
  47. data/testing/cucumber/step_definitions/setup_steps.rb +0 -32
  48. data/testing/cucumber/step_definitions/step_steps.rb +0 -3
  49. data/testing/cucumber/step_definitions/table_steps.rb +0 -1
  50. data/testing/cucumber/step_definitions/tag_steps.rb +0 -3
  51. data/testing/cucumber/step_definitions/verification_steps.rb +0 -181
  52. data/testing/cucumber/support/env.rb +0 -30
  53. data/testing/dialect_helper.rb +0 -48
  54. data/testing/file_helper.rb +0 -47
  55. data/testing/gemfiles/gherkin2.gemfile +0 -33
  56. data/testing/gemfiles/gherkin3.gemfile +0 -26
  57. data/testing/gemfiles/gherkin4.gemfile +0 -27
  58. data/testing/gemfiles/gherkin5.gemfile +0 -27
  59. data/testing/gemfiles/gherkin6.gemfile +0 -10
  60. data/testing/gemfiles/gherkin7.gemfile +0 -9
  61. data/testing/gemfiles/gherkin8.gemfile +0 -9
  62. data/testing/gemfiles/gherkin9.gemfile +0 -9
  63. data/testing/helper_methods.rb +0 -23
  64. data/testing/rspec/spec/integration/adapters/gherkin_2_adapter_spec.rb +0 -166
  65. data/testing/rspec/spec/integration/adapters/gherkin_3_adapter_spec.rb +0 -166
  66. data/testing/rspec/spec/integration/adapters/gherkin_4_adapter_spec.rb +0 -165
  67. data/testing/rspec/spec/integration/adapters/gherkin_5_adapter_spec.rb +0 -165
  68. data/testing/rspec/spec/integration/adapters/gherkin_6_adapter_spec.rb +0 -159
  69. data/testing/rspec/spec/integration/adapters/gherkin_7_adapter_spec.rb +0 -162
  70. data/testing/rspec/spec/integration/adapters/gherkin_8_adapter_spec.rb +0 -162
  71. data/testing/rspec/spec/integration/adapters/gherkin_9_adapter_spec.rb +0 -162
  72. data/testing/rspec/spec/integration/models/background_integration_spec.rb +0 -438
  73. data/testing/rspec/spec/integration/models/cell_integration_spec.rb +0 -338
  74. data/testing/rspec/spec/integration/models/comment_integration_spec.rb +0 -180
  75. data/testing/rspec/spec/integration/models/directory_integration_spec.rb +0 -218
  76. data/testing/rspec/spec/integration/models/doc_string_integration_spec.rb +0 -398
  77. data/testing/rspec/spec/integration/models/example_integration_spec.rb +0 -753
  78. data/testing/rspec/spec/integration/models/feature_file_integration_spec.rb +0 -276
  79. data/testing/rspec/spec/integration/models/feature_integration_spec.rb +0 -655
  80. data/testing/rspec/spec/integration/models/model_integration_spec.rb +0 -15
  81. data/testing/rspec/spec/integration/models/outline_integration_spec.rb +0 -619
  82. data/testing/rspec/spec/integration/models/row_integration_spec.rb +0 -303
  83. data/testing/rspec/spec/integration/models/scenario_integration_spec.rb +0 -475
  84. data/testing/rspec/spec/integration/models/step_integration_spec.rb +0 -573
  85. data/testing/rspec/spec/integration/models/table_integration_spec.rb +0 -333
  86. data/testing/rspec/spec/integration/models/tag_integration_spec.rb +0 -271
  87. data/testing/rspec/spec/integration/nested_integration_spec.rb +0 -91
  88. data/testing/rspec/spec/integration/parsing_integration_spec.rb +0 -143
  89. data/testing/rspec/spec/integration/shared/models_integration_specs.rb +0 -18
  90. data/testing/rspec/spec/spec_helper.rb +0 -129
  91. data/testing/rspec/spec/unit/cuke_modeler_unit_spec.rb +0 -25
  92. data/testing/rspec/spec/unit/described_unit_spec.rb +0 -23
  93. data/testing/rspec/spec/unit/models/background_unit_spec.rb +0 -83
  94. data/testing/rspec/spec/unit/models/cell_unit_spec.rb +0 -68
  95. data/testing/rspec/spec/unit/models/comment_unit_spec.rb +0 -68
  96. data/testing/rspec/spec/unit/models/directory_unit_spec.rb +0 -127
  97. data/testing/rspec/spec/unit/models/doc_string_unit_spec.rb +0 -100
  98. data/testing/rspec/spec/unit/models/example_unit_spec.rb +0 -133
  99. data/testing/rspec/spec/unit/models/feature_file_unit_spec.rb +0 -125
  100. data/testing/rspec/spec/unit/models/feature_unit_spec.rb +0 -157
  101. data/testing/rspec/spec/unit/models/model_unit_spec.rb +0 -15
  102. data/testing/rspec/spec/unit/models/outline_unit_spec.rb +0 -117
  103. data/testing/rspec/spec/unit/models/row_unit_spec.rb +0 -68
  104. data/testing/rspec/spec/unit/models/scenario_unit_spec.rb +0 -86
  105. data/testing/rspec/spec/unit/models/step_unit_spec.rb +0 -109
  106. data/testing/rspec/spec/unit/models/table_unit_spec.rb +0 -77
  107. data/testing/rspec/spec/unit/models/tag_unit_spec.rb +0 -68
  108. data/testing/rspec/spec/unit/named_unit_spec.rb +0 -23
  109. data/testing/rspec/spec/unit/nested_unit_spec.rb +0 -43
  110. data/testing/rspec/spec/unit/parsed_unit_spec.rb +0 -27
  111. data/testing/rspec/spec/unit/parsing_unit_spec.rb +0 -54
  112. data/testing/rspec/spec/unit/shared/bare_bones_models_unit_specs.rb +0 -14
  113. data/testing/rspec/spec/unit/shared/containing_models_unit_specs.rb +0 -127
  114. data/testing/rspec/spec/unit/shared/described_models_unit_specs.rb +0 -38
  115. data/testing/rspec/spec/unit/shared/keyworded_models_unit_specs.rb +0 -58
  116. data/testing/rspec/spec/unit/shared/models_unit_specs.rb +0 -15
  117. data/testing/rspec/spec/unit/shared/named_models_unit_specs.rb +0 -39
  118. data/testing/rspec/spec/unit/shared/nested_models_unit_specs.rb +0 -51
  119. data/testing/rspec/spec/unit/shared/parsed_models_unit_specs.rb +0 -39
  120. data/testing/rspec/spec/unit/shared/prepopulated_models_unit_specs.rb +0 -18
  121. data/testing/rspec/spec/unit/shared/sourced_models_unit_specs.rb +0 -39
  122. data/testing/rspec/spec/unit/shared/stepped_models_unit_specs.rb +0 -46
  123. data/testing/rspec/spec/unit/shared/stringifiable_models_unit_specs.rb +0 -18
  124. data/testing/rspec/spec/unit/shared/tagged_models_unit_specs.rb +0 -72
  125. data/testing/rspec/spec/unit/sourceable_unit_spec.rb +0 -27
  126. data/testing/rspec/spec/unit/stepped_unit_spec.rb +0 -23
  127. data/testing/rspec/spec/unit/taggable_unit_spec.rb +0 -69
  128. data/testing/test_languages.json +0 -45
  129. data/todo.txt +0 -25
@@ -1,333 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/../../spec_helper"
2
-
3
-
4
- describe 'Table, Integration' do
5
-
6
- let(:clazz) { CukeModeler::Table }
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 'provides a descriptive filename when being parsed from stand alone text' do
19
- source = 'bad table text'
20
-
21
- expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_table\.feature'/)
22
- end
23
-
24
- describe 'parsing data' do
25
-
26
- it 'stores the original data generated by the parsing adapter', :if => gherkin?(6, 7, 8, 9) do
27
- table = clazz.new("| a table |")
28
- data = table.parsing_data
29
-
30
- expect(data.keys).to match_array([:location, :rows])
31
- expect(data[:location][:line]).to eq(5)
32
- end
33
-
34
- it 'stores the original data generated by the parsing adapter', :if => gherkin?(3, 4, 5) do
35
- table = clazz.new("| a table |")
36
- data = table.parsing_data
37
-
38
- expect(data.keys).to match_array([:type, :location, :rows])
39
- expect(data[:type]).to eq(:DataTable)
40
- end
41
-
42
- it 'stores the original data generated by the parsing adapter', :if => gherkin?(2) do
43
- table = clazz.new("| a table |")
44
- data = table.parsing_data
45
-
46
- # There is no parsing data for the table itself, only its rows
47
- expect(data).to match_array([])
48
- end
49
-
50
- end
51
-
52
- it 'can be instantiated with the minimum viable Gherkin' do
53
- source = '| a table |'
54
-
55
- expect { clazz.new(source) }.to_not raise_error
56
- end
57
-
58
- it 'can parse text that uses a non-default dialect' do
59
- original_dialect = CukeModeler::Parsing.dialect
60
- CukeModeler::Parsing.dialect = 'en-au'
61
-
62
- begin
63
- source_text = '| a table |'
64
-
65
- expect { @model = clazz.new(source_text) }.to_not raise_error
66
-
67
- # Sanity check in case modeling failed in a non-explosive manner
68
- expect(@model.rows.first.cells.first.value).to eq('a table')
69
- ensure
70
- # Making sure that our changes don't escape a test and ruin the rest of the suite
71
- CukeModeler::Parsing.dialect = original_dialect
72
- end
73
- end
74
-
75
-
76
- describe 'model population' do
77
-
78
- context 'from source text' do
79
-
80
- it "models the table's source line" do
81
- source_text = "#{FEATURE_KEYWORD}:
82
-
83
- #{SCENARIO_KEYWORD}:
84
- #{STEP_KEYWORD} step
85
- | value |"
86
- table = CukeModeler::Feature.new(source_text).tests.first.steps.first.block
87
-
88
- expect(table.source_line).to eq(5)
89
- end
90
-
91
-
92
- context 'a filled table' do
93
-
94
- let(:source_text) { "| value 1 |
95
- | value 2 |" }
96
- let(:table) { clazz.new(source_text) }
97
-
98
-
99
- it "models the table's rows" do
100
- table_cell_values = table.rows.collect { |row| row.cells.collect { |cell| cell.value } }
101
-
102
- expect(table_cell_values).to eq([['value 1'], ['value 2']])
103
- end
104
-
105
- end
106
-
107
- end
108
-
109
- end
110
-
111
-
112
- it 'properly sets its child models' do
113
- source = "| cell 1 |
114
- | cell 2 |"
115
-
116
- table = clazz.new(source)
117
- row_1 = table.rows[0]
118
- row_2 = table.rows[1]
119
-
120
- expect(row_1.parent_model).to equal(table)
121
- expect(row_2.parent_model).to equal(table)
122
- end
123
-
124
- describe 'getting ancestors' do
125
-
126
- before(:each) do
127
- CukeModeler::FileHelper.create_feature_file(:text => source_gherkin, :name => 'table_test_file', :directory => test_directory)
128
- end
129
-
130
-
131
- let(:test_directory) { CukeModeler::FileHelper.create_directory }
132
- let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
133
-
134
- #{SCENARIO_KEYWORD}: Test test
135
- #{STEP_KEYWORD} a step:
136
- | a | table |"
137
- }
138
-
139
- let(:directory_model) { CukeModeler::Directory.new(test_directory) }
140
- let(:table_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block }
141
-
142
-
143
- it 'can get its directory' do
144
- ancestor = table_model.get_ancestor(:directory)
145
-
146
- expect(ancestor).to equal(directory_model)
147
- end
148
-
149
- it 'can get its feature file' do
150
- ancestor = table_model.get_ancestor(:feature_file)
151
-
152
- expect(ancestor).to equal(directory_model.feature_files.first)
153
- end
154
-
155
- it 'can get its feature' do
156
- ancestor = table_model.get_ancestor(:feature)
157
-
158
- expect(ancestor).to equal(directory_model.feature_files.first.feature)
159
- end
160
-
161
- context 'a table that is part of a scenario' do
162
-
163
- let(:test_directory) { CukeModeler::FileHelper.create_directory }
164
- let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
165
-
166
- #{SCENARIO_KEYWORD}: Test test
167
- #{STEP_KEYWORD} a step:
168
- | a | table |"
169
- }
170
-
171
- let(:directory_model) { CukeModeler::Directory.new(test_directory) }
172
- let(:table_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block }
173
-
174
-
175
- it 'can get its scenario' do
176
- ancestor = table_model.get_ancestor(:scenario)
177
-
178
- expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
179
- end
180
-
181
- end
182
-
183
- context 'a table that is part of an outline' do
184
-
185
- let(:test_directory) { CukeModeler::FileHelper.create_directory }
186
- let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
187
-
188
- #{OUTLINE_KEYWORD}: Test outline
189
- #{STEP_KEYWORD} a step:
190
- | a | table |
191
- #{EXAMPLE_KEYWORD}:
192
- | param |
193
- | value |"
194
- }
195
-
196
- let(:directory_model) { CukeModeler::Directory.new(test_directory) }
197
- let(:table_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block }
198
-
199
-
200
- it 'can get its outline' do
201
- ancestor = table_model.get_ancestor(:outline)
202
-
203
- expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
204
- end
205
-
206
- end
207
-
208
- context 'a table that is part of a background' do
209
-
210
- let(:test_directory) { CukeModeler::FileHelper.create_directory }
211
- let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
212
-
213
- #{BACKGROUND_KEYWORD}: Test background
214
- #{STEP_KEYWORD} a step:
215
- | a | table |"
216
- }
217
-
218
- let(:directory_model) { CukeModeler::Directory.new(test_directory) }
219
- let(:table_model) { directory_model.feature_files.first.feature.background.steps.first.block }
220
-
221
-
222
- it 'can get its background' do
223
- ancestor = table_model.get_ancestor(:background)
224
-
225
- expect(ancestor).to equal(directory_model.feature_files.first.feature.background)
226
- end
227
-
228
- end
229
-
230
- it 'can get its step' do
231
- ancestor = table_model.get_ancestor(:step)
232
-
233
- expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.steps.first)
234
- end
235
-
236
- it 'returns nil if it does not have the requested type of ancestor' do
237
- ancestor = table_model.get_ancestor(:example)
238
-
239
- expect(ancestor).to be_nil
240
- end
241
-
242
- end
243
-
244
-
245
- describe 'table output' do
246
-
247
- it 'can be remade from its own output' do
248
- source = "| value1 | value2 |
249
- | value3 | value4 |"
250
- table = clazz.new(source)
251
-
252
- table_output = table.to_s
253
- remade_table_output = clazz.new(table_output).to_s
254
-
255
- expect(remade_table_output).to eq(table_output)
256
- end
257
-
258
- # This behavior should already be taken care of by the cell object's output method, but
259
- # the table object has to adjust that output in order to properly buffer column width
260
- # and it is possible that during that process it messes up the cell's output.
261
-
262
- it 'can correctly output a row that has special characters in it' do
263
- source = ['| a value with \| |',
264
- '| a value with \\\\ |',
265
- '| a value with \\\\ and \| |']
266
- source = source.join("\n")
267
- table = clazz.new(source)
268
-
269
- table_output = table.to_s.split("\n", -1)
270
-
271
- expect(table_output).to eq(['| a value with \| |',
272
- '| a value with \\\\ |',
273
- '| a value with \\\\ and \| |'])
274
- end
275
-
276
- context 'from source text' do
277
-
278
- it 'can output an table that has a single row' do
279
- source = ['|value1|value2|']
280
- source = source.join("\n")
281
- table = clazz.new(source)
282
-
283
- table_output = table.to_s.split("\n", -1)
284
-
285
- expect(table_output).to eq(['| value1 | value2 |'])
286
- end
287
-
288
- it 'can output an table that has multiple rows' do
289
- source = ['|value1|value2|',
290
- '|value3|value4|']
291
- source = source.join("\n")
292
- table = clazz.new(source)
293
-
294
- table_output = table.to_s.split("\n", -1)
295
-
296
- expect(table_output).to eq(['| value1 | value2 |',
297
- '| value3 | value4 |'])
298
- end
299
-
300
- it 'buffers row cells based on the longest value in a column' do
301
- source = "|value 1| x|
302
- |y|value 2|
303
- |a|b|"
304
- table = clazz.new(source)
305
-
306
- table_output = table.to_s.split("\n", -1)
307
-
308
- expect(table_output).to eq(['| value 1 | x |',
309
- '| y | value 2 |',
310
- '| a | b |'])
311
- end
312
-
313
- end
314
-
315
-
316
- context 'from abstract instantiation' do
317
-
318
- let(:table) { clazz.new }
319
-
320
-
321
- it 'can output a table that only has rows' do
322
- table.rows = [CukeModeler::Row.new]
323
-
324
- expect { table.to_s }.to_not raise_error
325
- end
326
-
327
- end
328
-
329
- end
330
-
331
- end
332
-
333
- end
@@ -1,271 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/../../spec_helper"
2
-
3
-
4
- describe 'Tag, Integration' do
5
-
6
- let(:clazz) { CukeModeler::Tag }
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 = '@a_tag'
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 = '@foo'
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('@foo')
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 tag text'
42
-
43
- expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_tag\.feature'/)
44
- end
45
-
46
- describe 'parsing data' do
47
-
48
- it 'stores the original data generated by the parsing adapter', :if => gherkin?(8, 9) do
49
- tag = clazz.new('@a_tag')
50
- data = tag.parsing_data
51
-
52
- expect(data.keys).to match_array([:location, :name, :id])
53
- expect(data[:name]).to eq('@a_tag')
54
- end
55
-
56
- it 'stores the original data generated by the parsing adapter', :if => gherkin?(6, 7) do
57
- tag = clazz.new('@a_tag')
58
- data = tag.parsing_data
59
-
60
- expect(data.keys).to match_array([:location, :name])
61
- expect(data[:name]).to eq('@a_tag')
62
- end
63
-
64
- it 'stores the original data generated by the parsing adapter', :if => gherkin?(4, 5) do
65
- tag = clazz.new('@a_tag')
66
- data = tag.parsing_data
67
-
68
- expect(data.keys).to match_array([:type, :location, :name])
69
- expect(data[:type]).to eq(:Tag)
70
- end
71
-
72
- it 'stores the original data generated by the parsing adapter', :if => gherkin?(3) do
73
- tag = clazz.new('@a_tag')
74
- data = tag.parsing_data
75
-
76
- expect(data.keys).to match_array([:type, :location, :name])
77
- expect(data[:type]).to eq('Tag')
78
- end
79
-
80
- it 'stores the original data generated by the parsing adapter', :if => gherkin?(2) do
81
- tag = clazz.new('@a_tag')
82
- data = tag.parsing_data
83
-
84
- expect(data.keys).to match_array(['name', 'line'])
85
- expect(data['name']).to eq('@a_tag')
86
- end
87
-
88
- end
89
-
90
-
91
- describe 'getting ancestors' do
92
-
93
- before(:each) do
94
- CukeModeler::FileHelper.create_feature_file(:text => source_gherkin, :name => 'tag_test_file', :directory => test_directory)
95
- end
96
-
97
-
98
- let(:test_directory) { CukeModeler::FileHelper.create_directory }
99
- let(:source_gherkin) { "@feature_tag
100
- #{FEATURE_KEYWORD}: Test feature
101
-
102
- #{OUTLINE_KEYWORD}: Test test
103
- #{STEP_KEYWORD} a step
104
-
105
- @example_tag
106
- #{EXAMPLE_KEYWORD}: Test example
107
- | a param |
108
- | a value |"
109
- }
110
-
111
- let(:directory_model) { CukeModeler::Directory.new(test_directory) }
112
- let(:tag_model) { directory_model.feature_files.first.feature.tests.first.examples.first.tags.first }
113
- let(:high_level_tag_model) { directory_model.feature_files.first.feature.tags.first }
114
-
115
-
116
- it 'can get its directory' do
117
- ancestor = tag_model.get_ancestor(:directory)
118
-
119
- expect(ancestor).to equal(directory_model)
120
- end
121
-
122
- it 'can get its feature file' do
123
- ancestor = tag_model.get_ancestor(:feature_file)
124
-
125
- expect(ancestor).to equal(directory_model.feature_files.first)
126
- end
127
-
128
- it 'can get its feature' do
129
- ancestor = tag_model.get_ancestor(:feature)
130
-
131
- expect(ancestor).to equal(directory_model.feature_files.first.feature)
132
- end
133
-
134
- context 'a tag that is part of a scenario' do
135
-
136
- let(:test_directory) { CukeModeler::FileHelper.create_directory }
137
- let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
138
-
139
- @a_tag
140
- #{SCENARIO_KEYWORD}: Test scenario
141
- #{STEP_KEYWORD} a step"
142
- }
143
-
144
- let(:directory_model) { CukeModeler::Directory.new(test_directory) }
145
- let(:tag_model) { directory_model.feature_files.first.feature.tests.first.tags.first }
146
-
147
-
148
- it 'can get its scenario' do
149
- ancestor = tag_model.get_ancestor(:scenario)
150
-
151
- expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
152
- end
153
-
154
- end
155
-
156
- context 'a tag that is part of an outline' do
157
-
158
- let(:test_directory) { CukeModeler::FileHelper.create_directory }
159
- let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
160
-
161
- @a_tag
162
- #{OUTLINE_KEYWORD}: Test outline
163
- #{STEP_KEYWORD} a step
164
- #{EXAMPLE_KEYWORD}:
165
- | param |
166
- | value |"
167
- }
168
-
169
- let(:directory_model) { CukeModeler::Directory.new(test_directory) }
170
- let(:tag_model) { directory_model.feature_files.first.feature.tests.first.tags.first }
171
-
172
-
173
- it 'can get its outline' do
174
- ancestor = tag_model.get_ancestor(:outline)
175
-
176
- expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
177
- end
178
-
179
- end
180
-
181
- context 'a tag that is part of an example' do
182
-
183
- let(:test_directory) { CukeModeler::FileHelper.create_directory }
184
- let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
185
-
186
- #{OUTLINE_KEYWORD}: Test outline
187
- #{STEP_KEYWORD} a step
188
- @a_tag
189
- #{EXAMPLE_KEYWORD}:
190
- | param |
191
- | value |"
192
- }
193
-
194
- let(:directory_model) { CukeModeler::Directory.new(test_directory) }
195
- let(:tag_model) { directory_model.feature_files.first.feature.tests.first.examples.first.tags.first }
196
-
197
-
198
- it 'can get its example' do
199
- ancestor = tag_model.get_ancestor(:example)
200
-
201
- expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.examples.first)
202
- end
203
-
204
- end
205
-
206
- it 'returns nil if it does not have the requested type of ancestor' do
207
- ancestor = high_level_tag_model.get_ancestor(:example)
208
-
209
- expect(ancestor).to be_nil
210
- end
211
-
212
- end
213
-
214
-
215
- describe 'model population' do
216
-
217
- context 'from source text' do
218
-
219
- let(:source_text) { '@a_tag' }
220
- let(:tag) { clazz.new(source_text) }
221
-
222
-
223
- it "models the tag's name" do
224
- expect(tag.name).to eq('@a_tag')
225
- end
226
-
227
- it "models the tag's source line" do
228
- source_text = "#{FEATURE_KEYWORD}:
229
-
230
- @a_tag
231
- #{SCENARIO_KEYWORD}:
232
- #{STEP_KEYWORD} step"
233
- tag = CukeModeler::Feature.new(source_text).tests.first.tags.first
234
-
235
- expect(tag.source_line).to eq(3)
236
- end
237
-
238
- end
239
-
240
- end
241
-
242
-
243
- describe 'tag output' do
244
-
245
- it 'can be remade from its own output' do
246
- source = '@some_tag'
247
- tag = clazz.new(source)
248
-
249
- tag_output = tag.to_s
250
- remade_tag_output = clazz.new(tag_output).to_s
251
-
252
- expect(remade_tag_output).to eq(tag_output)
253
- end
254
-
255
-
256
- context 'from source text' do
257
-
258
- it 'can output a tag' do
259
- source = '@a_tag'
260
- tag = clazz.new(source)
261
-
262
- expect(tag.to_s).to eq('@a_tag')
263
- end
264
-
265
- end
266
-
267
- end
268
-
269
- end
270
-
271
- end