cuke_modeler 1.5.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +341 -0
- data/LICENSE.txt +1 -1
- data/README.md +22 -15
- data/cuke_modeler.gemspec +15 -9
- data/lib/cuke_modeler/adapters/gherkin_10_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/gherkin_11_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/gherkin_12_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/gherkin_13_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/gherkin_14_adapter.rb +12 -0
- data/lib/cuke_modeler/adapters/{gherkin_6_adapter.rb → gherkin_9_adapter.rb} +75 -64
- data/lib/cuke_modeler/containing.rb +3 -0
- data/lib/cuke_modeler/described.rb +1 -0
- data/lib/cuke_modeler/models/background.rb +1 -1
- data/lib/cuke_modeler/models/cell.rb +1 -1
- data/lib/cuke_modeler/models/comment.rb +1 -1
- data/lib/cuke_modeler/models/directory.rb +2 -2
- data/lib/cuke_modeler/models/doc_string.rb +1 -1
- data/lib/cuke_modeler/models/example.rb +1 -1
- data/lib/cuke_modeler/models/feature.rb +1 -1
- data/lib/cuke_modeler/models/feature_file.rb +2 -2
- data/lib/cuke_modeler/models/outline.rb +1 -1
- data/lib/cuke_modeler/models/row.rb +1 -1
- data/lib/cuke_modeler/models/scenario.rb +1 -1
- data/lib/cuke_modeler/models/step.rb +32 -3
- data/lib/cuke_modeler/models/table.rb +1 -1
- data/lib/cuke_modeler/models/tag.rb +1 -1
- data/lib/cuke_modeler/named.rb +1 -0
- data/lib/cuke_modeler/nested.rb +1 -0
- data/lib/cuke_modeler/parsed.rb +1 -0
- data/lib/cuke_modeler/parsing.rb +89 -94
- data/lib/cuke_modeler/sourceable.rb +1 -0
- data/lib/cuke_modeler/stepped.rb +1 -0
- data/lib/cuke_modeler/taggable.rb +1 -0
- data/lib/cuke_modeler/version.rb +1 -1
- data/testing/cucumber/features/analysis/step_comparison.feature +25 -0
- data/testing/cucumber/features/analysis/test_comparison.feature +1 -1
- metadata +56 -142
- data/.gitignore +0 -18
- data/.simplecov +0 -7
- data/.travis.yml +0 -60
- data/Gemfile +0 -36
- data/History.md +0 -196
- data/Rakefile +0 -63
- data/appveyor.yml +0 -61
- data/lib/cuke_modeler/adapters/gherkin_2_adapter.rb +0 -273
- data/lib/cuke_modeler/adapters/gherkin_3_adapter.rb +0 -296
- data/lib/cuke_modeler/adapters/gherkin_4_adapter.rb +0 -308
- data/testing/cucumber/step_definitions/action_steps.rb +0 -13
- data/testing/cucumber/step_definitions/background_steps.rb +0 -1
- data/testing/cucumber/step_definitions/directory_steps.rb +0 -6
- data/testing/cucumber/step_definitions/doc_string_steps.rb +0 -1
- data/testing/cucumber/step_definitions/feature_file_steps.rb +0 -16
- data/testing/cucumber/step_definitions/feature_steps.rb +0 -7
- data/testing/cucumber/step_definitions/modeling_steps.rb +0 -44
- data/testing/cucumber/step_definitions/setup_steps.rb +0 -32
- data/testing/cucumber/step_definitions/step_steps.rb +0 -3
- data/testing/cucumber/step_definitions/table_steps.rb +0 -1
- data/testing/cucumber/step_definitions/tag_steps.rb +0 -3
- data/testing/cucumber/step_definitions/verification_steps.rb +0 -173
- data/testing/cucumber/support/env.rb +0 -30
- data/testing/dialect_helper.rb +0 -48
- data/testing/file_helper.rb +0 -47
- data/testing/gemfiles/gherkin2.gemfile +0 -32
- data/testing/gemfiles/gherkin3.gemfile +0 -26
- data/testing/gemfiles/gherkin4.gemfile +0 -27
- data/testing/gemfiles/gherkin5.gemfile +0 -27
- data/testing/gemfiles/gherkin6.gemfile +0 -10
- data/testing/rspec/spec/integration/background_integration_spec.rb +0 -442
- data/testing/rspec/spec/integration/cell_integration_spec.rb +0 -335
- data/testing/rspec/spec/integration/comment_integration_spec.rb +0 -177
- data/testing/rspec/spec/integration/directory_integration_spec.rb +0 -218
- data/testing/rspec/spec/integration/doc_string_integration_spec.rb +0 -402
- data/testing/rspec/spec/integration/example_integration_spec.rb +0 -741
- data/testing/rspec/spec/integration/feature_file_integration_spec.rb +0 -272
- data/testing/rspec/spec/integration/feature_integration_spec.rb +0 -650
- data/testing/rspec/spec/integration/gherkin_2_adapter_spec.rb +0 -166
- data/testing/rspec/spec/integration/gherkin_3_adapter_spec.rb +0 -166
- data/testing/rspec/spec/integration/gherkin_4_adapter_spec.rb +0 -165
- data/testing/rspec/spec/integration/gherkin_6_adapter_spec.rb +0 -166
- data/testing/rspec/spec/integration/model_integration_spec.rb +0 -15
- data/testing/rspec/spec/integration/nested_integration_spec.rb +0 -91
- data/testing/rspec/spec/integration/outline_integration_spec.rb +0 -624
- data/testing/rspec/spec/integration/parsing_integration_spec.rb +0 -122
- data/testing/rspec/spec/integration/row_integration_spec.rb +0 -291
- data/testing/rspec/spec/integration/scenario_integration_spec.rb +0 -479
- data/testing/rspec/spec/integration/shared/models_integration_specs.rb +0 -18
- data/testing/rspec/spec/integration/step_integration_spec.rb +0 -475
- data/testing/rspec/spec/integration/table_integration_spec.rb +0 -337
- data/testing/rspec/spec/integration/tag_integration_spec.rb +0 -259
- data/testing/rspec/spec/spec_helper.rb +0 -122
- data/testing/rspec/spec/unit/background_unit_spec.rb +0 -83
- data/testing/rspec/spec/unit/cell_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/comment_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/described_unit_spec.rb +0 -23
- data/testing/rspec/spec/unit/directory_unit_spec.rb +0 -127
- data/testing/rspec/spec/unit/doc_string_unit_spec.rb +0 -100
- data/testing/rspec/spec/unit/example_unit_spec.rb +0 -133
- data/testing/rspec/spec/unit/feature_file_unit_spec.rb +0 -125
- data/testing/rspec/spec/unit/feature_unit_spec.rb +0 -157
- data/testing/rspec/spec/unit/model_unit_spec.rb +0 -15
- data/testing/rspec/spec/unit/named_unit_spec.rb +0 -23
- data/testing/rspec/spec/unit/nested_unit_spec.rb +0 -43
- data/testing/rspec/spec/unit/outline_unit_spec.rb +0 -117
- data/testing/rspec/spec/unit/parsed_unit_spec.rb +0 -27
- data/testing/rspec/spec/unit/parsing_unit_spec.rb +0 -54
- data/testing/rspec/spec/unit/row_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/scenario_unit_spec.rb +0 -86
- data/testing/rspec/spec/unit/shared/bare_bones_models_unit_specs.rb +0 -14
- data/testing/rspec/spec/unit/shared/containing_models_unit_specs.rb +0 -127
- data/testing/rspec/spec/unit/shared/described_models_unit_specs.rb +0 -38
- data/testing/rspec/spec/unit/shared/keyworded_models_unit_specs.rb +0 -58
- data/testing/rspec/spec/unit/shared/models_unit_specs.rb +0 -15
- data/testing/rspec/spec/unit/shared/named_models_unit_specs.rb +0 -39
- data/testing/rspec/spec/unit/shared/nested_models_unit_specs.rb +0 -51
- data/testing/rspec/spec/unit/shared/parsed_models_unit_specs.rb +0 -39
- data/testing/rspec/spec/unit/shared/prepopulated_models_unit_specs.rb +0 -18
- data/testing/rspec/spec/unit/shared/sourced_models_unit_specs.rb +0 -39
- data/testing/rspec/spec/unit/shared/stepped_models_unit_specs.rb +0 -46
- data/testing/rspec/spec/unit/shared/stringifiable_models_unit_specs.rb +0 -18
- data/testing/rspec/spec/unit/shared/tagged_models_unit_specs.rb +0 -72
- data/testing/rspec/spec/unit/sourceable_unit_spec.rb +0 -27
- data/testing/rspec/spec/unit/step_unit_spec.rb +0 -109
- data/testing/rspec/spec/unit/stepped_unit_spec.rb +0 -23
- data/testing/rspec/spec/unit/table_unit_spec.rb +0 -77
- data/testing/rspec/spec/unit/tag_unit_spec.rb +0 -68
- data/testing/rspec/spec/unit/taggable_unit_spec.rb +0 -69
- data/testing/test_languages.json +0 -45
- data/todo.txt +0 -24
@@ -1,335 +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
|
-
it 'stores the original data generated by the parsing adapter', :gherkin6 => true do
|
48
|
-
cell = clazz.new('a cell')
|
49
|
-
data = cell.parsing_data
|
50
|
-
|
51
|
-
expect(data.keys).to match_array([:location, :value])
|
52
|
-
expect(data[:value]).to eq('a cell')
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'stores the original data generated by the parsing adapter', :gherkin4_5 => true do
|
56
|
-
cell = clazz.new('a cell')
|
57
|
-
data = cell.parsing_data
|
58
|
-
|
59
|
-
expect(data.keys).to match_array([:type, :location, :value])
|
60
|
-
expect(data[:type]).to eq(:TableCell)
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
|
64
|
-
cell = clazz.new("a cell")
|
65
|
-
data = cell.parsing_data
|
66
|
-
|
67
|
-
expect(data.keys).to match_array([:type, :location, :value])
|
68
|
-
expect(data[:type]).to eq('TableCell')
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
|
72
|
-
cell = clazz.new("a cell")
|
73
|
-
data = cell.parsing_data
|
74
|
-
|
75
|
-
# Cells did not exist as full fledged objects in the Gherkin2 parser
|
76
|
-
expect(data).to eq('a cell')
|
77
|
-
end
|
78
|
-
|
79
|
-
|
80
|
-
describe 'getting ancestors' do
|
81
|
-
|
82
|
-
before(:each) do
|
83
|
-
CukeModeler::FileHelper.create_feature_file(:text => source_gherkin, :name => 'cell_test_file', :directory => test_directory)
|
84
|
-
end
|
85
|
-
|
86
|
-
|
87
|
-
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
88
|
-
let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
|
89
|
-
|
90
|
-
#{SCENARIO_KEYWORD}: Test test
|
91
|
-
#{STEP_KEYWORD} a step
|
92
|
-
| a value |"
|
93
|
-
}
|
94
|
-
|
95
|
-
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
96
|
-
let(:cell_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block.rows.first.cells.first }
|
97
|
-
|
98
|
-
|
99
|
-
it 'can get its directory' do
|
100
|
-
ancestor = cell_model.get_ancestor(:directory)
|
101
|
-
|
102
|
-
expect(ancestor).to equal(directory_model)
|
103
|
-
end
|
104
|
-
|
105
|
-
it 'can get its feature file' do
|
106
|
-
ancestor = cell_model.get_ancestor(:feature_file)
|
107
|
-
|
108
|
-
expect(ancestor).to equal(directory_model.feature_files.first)
|
109
|
-
end
|
110
|
-
|
111
|
-
it 'can get its feature' do
|
112
|
-
ancestor = cell_model.get_ancestor(:feature)
|
113
|
-
|
114
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature)
|
115
|
-
end
|
116
|
-
|
117
|
-
context 'a cell that is part of an outline' do
|
118
|
-
|
119
|
-
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
120
|
-
let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
|
121
|
-
|
122
|
-
#{OUTLINE_KEYWORD}: Test outline
|
123
|
-
#{STEP_KEYWORD} a step
|
124
|
-
#{EXAMPLE_KEYWORD}:
|
125
|
-
| param |
|
126
|
-
| value |"
|
127
|
-
}
|
128
|
-
|
129
|
-
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
130
|
-
let(:cell_model) { directory_model.feature_files.first.feature.tests.first.examples.first.rows.first.cells.first }
|
131
|
-
|
132
|
-
|
133
|
-
it 'can get its outline' do
|
134
|
-
ancestor = cell_model.get_ancestor(:outline)
|
135
|
-
|
136
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
|
137
|
-
end
|
138
|
-
|
139
|
-
it 'can get its example' do
|
140
|
-
ancestor = cell_model.get_ancestor(:example)
|
141
|
-
|
142
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.examples.first)
|
143
|
-
end
|
144
|
-
|
145
|
-
it 'can get its row' do
|
146
|
-
ancestor = cell_model.get_ancestor(:row)
|
147
|
-
|
148
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.examples.first.rows.first)
|
149
|
-
end
|
150
|
-
|
151
|
-
end
|
152
|
-
|
153
|
-
|
154
|
-
context 'a cell that is part of a scenario' do
|
155
|
-
|
156
|
-
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
157
|
-
let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
|
158
|
-
|
159
|
-
#{SCENARIO_KEYWORD}: Test test
|
160
|
-
#{STEP_KEYWORD} a step:
|
161
|
-
| a | table |"
|
162
|
-
}
|
163
|
-
|
164
|
-
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
165
|
-
let(:cell_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block.rows.first.cells.first }
|
166
|
-
|
167
|
-
|
168
|
-
it 'can get its scenario' do
|
169
|
-
ancestor = cell_model.get_ancestor(:scenario)
|
170
|
-
|
171
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first)
|
172
|
-
end
|
173
|
-
|
174
|
-
end
|
175
|
-
|
176
|
-
context 'a cell that is part of a background' do
|
177
|
-
|
178
|
-
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
179
|
-
let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
|
180
|
-
|
181
|
-
#{BACKGROUND_KEYWORD}: Test background
|
182
|
-
#{STEP_KEYWORD} a step:
|
183
|
-
| a | table |"
|
184
|
-
}
|
185
|
-
|
186
|
-
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
187
|
-
let(:cell_model) { directory_model.feature_files.first.feature.background.steps.first.block.rows.first.cells.first }
|
188
|
-
|
189
|
-
|
190
|
-
it 'can get its background' do
|
191
|
-
ancestor = cell_model.get_ancestor(:background)
|
192
|
-
|
193
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature.background)
|
194
|
-
end
|
195
|
-
|
196
|
-
end
|
197
|
-
|
198
|
-
context 'a cell that is part of a step' do
|
199
|
-
|
200
|
-
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
201
|
-
let(:source_gherkin) { "#{FEATURE_KEYWORD}: Test feature
|
202
|
-
|
203
|
-
#{SCENARIO_KEYWORD}: Test test
|
204
|
-
#{STEP_KEYWORD} a step:
|
205
|
-
| a | table |"
|
206
|
-
}
|
207
|
-
|
208
|
-
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
209
|
-
let(:cell_model) { directory_model.feature_files.first.feature.tests.first.steps.first.block.rows.first.cells.first }
|
210
|
-
|
211
|
-
|
212
|
-
it 'can get its step' do
|
213
|
-
ancestor = cell_model.get_ancestor(:step)
|
214
|
-
|
215
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.steps.first)
|
216
|
-
end
|
217
|
-
|
218
|
-
it 'can get its table' do
|
219
|
-
ancestor = cell_model.get_ancestor(:table)
|
220
|
-
|
221
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.steps.first.block)
|
222
|
-
end
|
223
|
-
|
224
|
-
it 'can get its row' do
|
225
|
-
ancestor = cell_model.get_ancestor(:row)
|
226
|
-
|
227
|
-
expect(ancestor).to equal(directory_model.feature_files.first.feature.tests.first.steps.first.block.rows.first)
|
228
|
-
end
|
229
|
-
|
230
|
-
end
|
231
|
-
|
232
|
-
it 'returns nil if it does not have the requested type of ancestor' do
|
233
|
-
ancestor = cell_model.get_ancestor(:example)
|
234
|
-
|
235
|
-
expect(ancestor).to be_nil
|
236
|
-
end
|
237
|
-
|
238
|
-
end
|
239
|
-
|
240
|
-
|
241
|
-
describe 'model population' do
|
242
|
-
|
243
|
-
context 'from source text' do
|
244
|
-
|
245
|
-
let(:source_text) { 'a cell' }
|
246
|
-
let(:cell) { clazz.new(source_text) }
|
247
|
-
|
248
|
-
|
249
|
-
it "models the cell's value" do
|
250
|
-
expect(cell.value).to eq('a cell')
|
251
|
-
end
|
252
|
-
|
253
|
-
it "models the cell's source line" do
|
254
|
-
source_text = "#{FEATURE_KEYWORD}:
|
255
|
-
|
256
|
-
#{SCENARIO_KEYWORD}:
|
257
|
-
#{STEP_KEYWORD} a step
|
258
|
-
| value |"
|
259
|
-
cell = CukeModeler::Feature.new(source_text).tests.first.steps.first.block.rows.first.cells.first
|
260
|
-
|
261
|
-
expect(cell.source_line).to eq(5)
|
262
|
-
end
|
263
|
-
|
264
|
-
end
|
265
|
-
|
266
|
-
end
|
267
|
-
|
268
|
-
|
269
|
-
describe 'cell output' do
|
270
|
-
|
271
|
-
it 'can be remade from its own output' do
|
272
|
-
source = 'a \\\\ complex \| cell'
|
273
|
-
cell = clazz.new(source)
|
274
|
-
|
275
|
-
cell_output = cell.to_s
|
276
|
-
remade_cell_output = clazz.new(cell_output).to_s
|
277
|
-
|
278
|
-
expect(remade_cell_output).to eq(cell_output)
|
279
|
-
end
|
280
|
-
|
281
|
-
|
282
|
-
context 'from source text' do
|
283
|
-
|
284
|
-
it 'can output a cell' do
|
285
|
-
source = 'a cell'
|
286
|
-
cell = clazz.new(source)
|
287
|
-
|
288
|
-
expect(cell.to_s).to eq('a cell')
|
289
|
-
end
|
290
|
-
|
291
|
-
# Because vertical bars mark the beginning and end of a cell, any vertical bars inside
|
292
|
-
# of the cell (which would have had to have been escaped to get inside of the cell in
|
293
|
-
# the first place) will be escaped when outputted so as to retain the quality of being
|
294
|
-
# able to use the output directly as Gherkin.
|
295
|
-
|
296
|
-
it 'can output a cell that has vertical bars in it' do
|
297
|
-
source = 'cell with a \| in it'
|
298
|
-
cell = clazz.new(source)
|
299
|
-
|
300
|
-
cell_output = cell.to_s
|
301
|
-
|
302
|
-
expect(cell_output).to eq('cell with a \| in it')
|
303
|
-
end
|
304
|
-
|
305
|
-
# Because backslashes are used to escape special characters, any backslashes inside
|
306
|
-
# of the cell (which would have had to have been escaped to get inside of the cell in
|
307
|
-
# the first place) will be escaped when outputted so as to retain the quality of being
|
308
|
-
# able to use the output directly as Gherkin.
|
309
|
-
|
310
|
-
it 'can output a cell that has backslashes in it' do
|
311
|
-
source = 'cell with a \\\\ in it'
|
312
|
-
cell = clazz.new(source)
|
313
|
-
|
314
|
-
cell_output = cell.to_s
|
315
|
-
|
316
|
-
expect(cell_output).to eq('cell with a \\\\ in it')
|
317
|
-
end
|
318
|
-
|
319
|
-
# Depending on the order in which special characters are escaped, extra backslashes might occur.
|
320
|
-
it 'can output a cell that has several kinds of special characters in it' do
|
321
|
-
source = 'cell with a \\\\ and \| in it'
|
322
|
-
cell = clazz.new(source)
|
323
|
-
|
324
|
-
cell_output = cell.to_s
|
325
|
-
|
326
|
-
expect(cell_output).to eq('cell with a \\\\ and \| in it')
|
327
|
-
end
|
328
|
-
|
329
|
-
end
|
330
|
-
|
331
|
-
end
|
332
|
-
|
333
|
-
end
|
334
|
-
|
335
|
-
end
|
@@ -1,177 +0,0 @@
|
|
1
|
-
require "#{File.dirname(__FILE__)}/../spec_helper"
|
2
|
-
|
3
|
-
|
4
|
-
describe 'Comment, Integration' do
|
5
|
-
|
6
|
-
let(:clazz) { CukeModeler::Comment }
|
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 = '# a comment'
|
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 = '# a comment'
|
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.text).to eq('# a comment')
|
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 = 'bad comment text'
|
43
|
-
|
44
|
-
expect { clazz.new(source) }.to raise_error(/'cuke_modeler_stand_alone_comment\.feature'/)
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'stores the original data generated by the parsing adapter', :gherkin6 => true do
|
48
|
-
comment = clazz.new('# a comment')
|
49
|
-
data = comment.parsing_data
|
50
|
-
|
51
|
-
expect(data.keys).to match_array([:location, :text])
|
52
|
-
expect(data[:text]).to eq('# a comment')
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'stores the original data generated by the parsing adapter', :gherkin4_5 => true do
|
56
|
-
comment = clazz.new('# a comment')
|
57
|
-
data = comment.parsing_data
|
58
|
-
|
59
|
-
expect(data.keys).to match_array([:type, :location, :text])
|
60
|
-
expect(data[:type]).to eq(:Comment)
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
|
64
|
-
comment = clazz.new('# a comment')
|
65
|
-
data = comment.parsing_data
|
66
|
-
|
67
|
-
expect(data.keys).to match_array([:type, :location, :text])
|
68
|
-
expect(data[:type]).to eq('Comment')
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
|
72
|
-
comment = clazz.new('# a comment')
|
73
|
-
data = comment.parsing_data
|
74
|
-
|
75
|
-
expect(data.keys).to match_array(['value', 'line'])
|
76
|
-
end
|
77
|
-
|
78
|
-
|
79
|
-
describe 'getting ancestors' do
|
80
|
-
|
81
|
-
before(:each) do
|
82
|
-
CukeModeler::FileHelper.create_feature_file(:text => source_gherkin, :name => 'comment_test_file', :directory => test_directory)
|
83
|
-
end
|
84
|
-
|
85
|
-
|
86
|
-
let(:test_directory) { CukeModeler::FileHelper.create_directory }
|
87
|
-
let(:source_gherkin) { "# feature comment
|
88
|
-
#{FEATURE_KEYWORD}: Test feature"
|
89
|
-
}
|
90
|
-
|
91
|
-
let(:directory_model) { CukeModeler::Directory.new(test_directory) }
|
92
|
-
let(:comment_model) { directory_model.feature_files.first.comments.first }
|
93
|
-
|
94
|
-
|
95
|
-
it 'can get its directory' do
|
96
|
-
ancestor = comment_model.get_ancestor(:directory)
|
97
|
-
|
98
|
-
expect(ancestor).to equal(directory_model)
|
99
|
-
end
|
100
|
-
|
101
|
-
it 'can get its feature file' do
|
102
|
-
ancestor = comment_model.get_ancestor(:feature_file)
|
103
|
-
|
104
|
-
expect(ancestor).to equal(directory_model.feature_files.first)
|
105
|
-
end
|
106
|
-
|
107
|
-
it 'returns nil if it does not have the requested type of ancestor' do
|
108
|
-
ancestor = comment_model.get_ancestor(:example)
|
109
|
-
|
110
|
-
expect(ancestor).to be_nil
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
|
-
|
116
|
-
describe 'model population' do
|
117
|
-
|
118
|
-
context 'from source text' do
|
119
|
-
|
120
|
-
let(:source_text) { '# a comment' }
|
121
|
-
let(:comment) { clazz.new(source_text) }
|
122
|
-
|
123
|
-
|
124
|
-
it "models the comment's text" do
|
125
|
-
expect(comment.text).to eq('# a comment')
|
126
|
-
end
|
127
|
-
|
128
|
-
it "models the comment's source line" do
|
129
|
-
source_text = "# a comment
|
130
|
-
#{FEATURE_KEYWORD}:"
|
131
|
-
|
132
|
-
test_file_path = CukeModeler::FileHelper.create_feature_file(:text => source_text, :name => 'comment_test_file')
|
133
|
-
comment = CukeModeler::FeatureFile.new(test_file_path).comments.first
|
134
|
-
|
135
|
-
expect(comment.source_line).to eq(1)
|
136
|
-
end
|
137
|
-
|
138
|
-
it 'removes surrounding whitespace' do
|
139
|
-
comment = clazz.new(' # a comment ')
|
140
|
-
|
141
|
-
expect(comment.text).to eq('# a comment')
|
142
|
-
end
|
143
|
-
|
144
|
-
end
|
145
|
-
|
146
|
-
end
|
147
|
-
|
148
|
-
|
149
|
-
describe 'comment output' do
|
150
|
-
|
151
|
-
it 'can be remade from its own output' do
|
152
|
-
source = '# a comment'
|
153
|
-
comment = clazz.new(source)
|
154
|
-
|
155
|
-
comment_output = comment.to_s
|
156
|
-
remade_comment_output = clazz.new(comment_output).to_s
|
157
|
-
|
158
|
-
expect(remade_comment_output).to eq(comment_output)
|
159
|
-
end
|
160
|
-
|
161
|
-
|
162
|
-
context 'from source text' do
|
163
|
-
|
164
|
-
it 'can output a comment' do
|
165
|
-
source = '# a comment'
|
166
|
-
comment = clazz.new(source)
|
167
|
-
|
168
|
-
expect(comment.to_s).to eq('# a comment')
|
169
|
-
end
|
170
|
-
|
171
|
-
end
|
172
|
-
|
173
|
-
end
|
174
|
-
|
175
|
-
end
|
176
|
-
|
177
|
-
end
|