cuke_modeler 1.4.0 → 3.0.0

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