cuporter 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +3 -2
- data/lib/cuporter/example_set_node.rb +0 -4
- data/lib/cuporter/feature_parser.rb +7 -5
- data/lib/cuporter/formatters/cuporter.css +9 -2
- data/lib/cuporter/formatters/html_node_writer.rb +4 -1
- data/lib/cuporter/node.rb +3 -16
- data/lib/cuporter/tag_list_node.rb +15 -0
- data/lib/cuporter/tag_report.rb +2 -2
- metadata +21 -19
- data/features/pretty_print.feature +0 -7
- data/features/step_definitions/cuporter_steps.rb +0 -8
- data/features/support/env.rb +0 -2
- data/spec/cuporter/example_set_node_spec.rb +0 -26
- data/spec/cuporter/feature_parser_spec.rb +0 -78
- data/spec/cuporter/functional/scenario_outlines_spec.rb +0 -431
- data/spec/cuporter/functional/single_feature_spec.rb +0 -65
- data/spec/cuporter/node_numberer_spec.rb +0 -80
- data/spec/cuporter/node_spec.rb +0 -81
- data/spec/cuporter/sort_node_spec.rb +0 -187
- data/spec/cuporter/support/functional/cli.rb +0 -10
- data/spec/cuporter/tag_list_node_spec.rb +0 -289
- data/spec/spec_helper.rb +0 -8
@@ -1,431 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Cuporter
|
4
|
-
|
5
|
-
describe "Tag Reports of Scenario Outlines in Single Features" do
|
6
|
-
|
7
|
-
context "scenario outline with 2 examples" do
|
8
|
-
context "1 example tag" do
|
9
|
-
it "returns 1 tag mapped to 1 example" do
|
10
|
-
report = one_feature( "fixtures/scenario_outline_with_2_examples/1_example_tag.feature")
|
11
|
-
report.should == <<EOF
|
12
|
-
@smoke
|
13
|
-
Feature: foo
|
14
|
-
Scenario Outline: outline
|
15
|
-
Scenarios: bang
|
16
|
-
|foo|bar|fan|
|
17
|
-
| 1 | 2 | 3 |
|
18
|
-
| 4 | 5 | 6 |
|
19
|
-
EOF
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
context "1 tag per example" do
|
24
|
-
it "returns 2 examples mapped to a tag" do
|
25
|
-
report = one_feature( "fixtures/scenario_outline_with_2_examples/1_tag_per_example.feature")
|
26
|
-
report.should == <<EOF
|
27
|
-
@smoke
|
28
|
-
Feature: foo
|
29
|
-
Scenario Outline: some
|
30
|
-
Scenarios: yet
|
31
|
-
|foo|bar|fan|
|
32
|
-
| 1 | 2 | 3 |
|
33
|
-
| 4 | 5 | 6 |
|
34
|
-
@wip
|
35
|
-
Feature: foo
|
36
|
-
Scenario Outline: some
|
37
|
-
Scenarios: another
|
38
|
-
|foo|bar|fan|
|
39
|
-
| 7 | 8 | 9 |
|
40
|
-
| 0 | 1 | 2 |
|
41
|
-
EOF
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
context "1 tag per example, 2 feature tags" do
|
46
|
-
it "returns 4 tags . . ." do
|
47
|
-
report = one_feature( "fixtures/scenario_outline_with_2_examples/1_tag_per_example_2_feature_tags.feature")
|
48
|
-
report.should == <<EOF
|
49
|
-
@smoke
|
50
|
-
Feature: foo
|
51
|
-
Scenario Outline: outline
|
52
|
-
Scenarios: yet
|
53
|
-
|foo|bar|fan|
|
54
|
-
| 1 | 2 | 3 |
|
55
|
-
| 4 | 5 | 6 |
|
56
|
-
@taggy
|
57
|
-
Feature: foo
|
58
|
-
Scenario Outline: outline
|
59
|
-
Scenarios: another
|
60
|
-
|foo|bar|fan|
|
61
|
-
| 1 | 2 | 3 |
|
62
|
-
| 4 | 5 | 6 |
|
63
|
-
Scenarios: yet
|
64
|
-
|foo|bar|fan|
|
65
|
-
| 1 | 2 | 3 |
|
66
|
-
| 4 | 5 | 6 |
|
67
|
-
@waggy
|
68
|
-
Feature: foo
|
69
|
-
Scenario Outline: outline
|
70
|
-
Scenarios: another
|
71
|
-
|foo|bar|fan|
|
72
|
-
| 1 | 2 | 3 |
|
73
|
-
| 4 | 5 | 6 |
|
74
|
-
Scenarios: yet
|
75
|
-
|foo|bar|fan|
|
76
|
-
| 1 | 2 | 3 |
|
77
|
-
| 4 | 5 | 6 |
|
78
|
-
@wip
|
79
|
-
Feature: foo
|
80
|
-
Scenario Outline: outline
|
81
|
-
Scenarios: another
|
82
|
-
|foo|bar|fan|
|
83
|
-
| 1 | 2 | 3 |
|
84
|
-
| 4 | 5 | 6 |
|
85
|
-
EOF
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
context "1 example tag and 1 feature tag" do
|
90
|
-
it "returns 2 tags" do
|
91
|
-
report = one_feature( "fixtures/scenario_outline_with_2_examples/1_example_tag_and_1_feature_tag.feature")
|
92
|
-
report.should == <<EOF
|
93
|
-
@f_tag
|
94
|
-
Feature: foo
|
95
|
-
Scenario Outline: outline
|
96
|
-
Scenarios: another
|
97
|
-
|foo|bar|fan|
|
98
|
-
| 1 | 2 | 3 |
|
99
|
-
| 4 | 5 | 6 |
|
100
|
-
Scenarios: yet
|
101
|
-
|foo|bar|fan|
|
102
|
-
| 1 | 2 | 3 |
|
103
|
-
| 4 | 5 | 6 |
|
104
|
-
@smoke
|
105
|
-
Feature: foo
|
106
|
-
Scenario Outline: outline
|
107
|
-
Scenarios: yet
|
108
|
-
|foo|bar|fan|
|
109
|
-
| 1 | 2 | 3 |
|
110
|
-
| 4 | 5 | 6 |
|
111
|
-
EOF
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
context "1 example tag and 1 scenario outline tag" do
|
116
|
-
it "returns 1 example mapped to 1 tag" do
|
117
|
-
report = one_feature( "fixtures/scenario_outline_with_2_examples/1_example_tag_and_1_scenario_outline_tag.feature")
|
118
|
-
report.should == <<EOF
|
119
|
-
@s_o_tag
|
120
|
-
Feature: foo
|
121
|
-
Scenario Outline: outline
|
122
|
-
Scenarios: another
|
123
|
-
|foo|bar|fan|
|
124
|
-
| 1 | 2 | 3 |
|
125
|
-
| 4 | 5 | 6 |
|
126
|
-
Scenarios: yet
|
127
|
-
|foo|bar|fan|
|
128
|
-
| 1 | 2 | 3 |
|
129
|
-
| 4 | 5 | 6 |
|
130
|
-
@smoke
|
131
|
-
Feature: foo
|
132
|
-
Scenario Outline: outline
|
133
|
-
Scenarios: yet
|
134
|
-
|foo|bar|fan|
|
135
|
-
| 1 | 2 | 3 |
|
136
|
-
| 4 | 5 | 6 |
|
137
|
-
EOF
|
138
|
-
end
|
139
|
-
end
|
140
|
-
context "1 example tag, 1 scenario outline tag, 1 feature tag" do
|
141
|
-
it "3 tags" do
|
142
|
-
report = one_feature( "fixtures/scenario_outline_with_2_examples/1_example_tag_1_scenario_outline_tag_1_feature_tag.feature")
|
143
|
-
report.should == <<EOF
|
144
|
-
@f_tag
|
145
|
-
Feature: foo
|
146
|
-
Scenario Outline: outline
|
147
|
-
Scenarios: another
|
148
|
-
|foo|bar|fan|
|
149
|
-
| 1 | 2 | 3 |
|
150
|
-
| 4 | 5 | 6 |
|
151
|
-
Scenarios: yet
|
152
|
-
|foo|bar|fan|
|
153
|
-
| 1 | 2 | 3 |
|
154
|
-
| 4 | 5 | 6 |
|
155
|
-
@s_o_tag
|
156
|
-
Feature: foo
|
157
|
-
Scenario Outline: outline
|
158
|
-
Scenarios: another
|
159
|
-
|foo|bar|fan|
|
160
|
-
| 1 | 2 | 3 |
|
161
|
-
| 4 | 5 | 6 |
|
162
|
-
Scenarios: yet
|
163
|
-
|foo|bar|fan|
|
164
|
-
| 1 | 2 | 3 |
|
165
|
-
| 4 | 5 | 6 |
|
166
|
-
@smoke
|
167
|
-
Feature: foo
|
168
|
-
Scenario Outline: outline
|
169
|
-
Scenarios: yet
|
170
|
-
|foo|bar|fan|
|
171
|
-
| 1 | 2 | 3 |
|
172
|
-
| 4 | 5 | 6 |
|
173
|
-
EOF
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
context "1 scenario and 1 outline with 2 examples" do
|
179
|
-
context "1 scenario tag, 1 outline tag" do
|
180
|
-
it "returns 2 tags, 1 with a scenario, 1 with an outline" do
|
181
|
-
report = one_feature( "fixtures/1_scenario_and_1_outline_with_2_examples/1_scenario_tag_1_outline_tag.feature")
|
182
|
-
report.should == <<EOF
|
183
|
-
@s_o_tag
|
184
|
-
Feature: foo
|
185
|
-
Scenario Outline: outline
|
186
|
-
Scenarios: another
|
187
|
-
|foo|bar|fan|
|
188
|
-
| 1 | 2 | 3 |
|
189
|
-
| 4 | 5 | 6 |
|
190
|
-
Scenarios: yet
|
191
|
-
|foo|bar|fan|
|
192
|
-
| 1 | 2 | 3 |
|
193
|
-
| 4 | 5 | 6 |
|
194
|
-
@s_tag
|
195
|
-
Feature: foo
|
196
|
-
Scenario: oh
|
197
|
-
EOF
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
context "1 scenario tag, 1 example tag" do
|
202
|
-
it "returns 2 tags, 1 with a scenario and 1 with an outline" do
|
203
|
-
report = one_feature( "fixtures/1_scenario_and_1_outline_with_2_examples/1_scenario_tag_1_example_tag.feature")
|
204
|
-
report.should == <<EOF
|
205
|
-
@s_o_tag
|
206
|
-
Feature: foo
|
207
|
-
Scenario Outline: outline
|
208
|
-
Scenarios: another
|
209
|
-
|foo|bar|fan|
|
210
|
-
| 1 | 2 | 3 |
|
211
|
-
| 4 | 5 | 6 |
|
212
|
-
@s_tag
|
213
|
-
Feature: foo
|
214
|
-
Scenario: oh
|
215
|
-
EOF
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
context "1 feature tag, 1 example tag" do
|
220
|
-
it "returns 2 tags" do
|
221
|
-
report = one_feature( "fixtures/1_scenario_and_1_outline_with_2_examples/1_feature_tag_1_example_tag.feature")
|
222
|
-
report.should == <<EOF
|
223
|
-
@example_tag
|
224
|
-
Feature: foo
|
225
|
-
Scenario Outline: outline
|
226
|
-
Scenarios: another
|
227
|
-
|foo|bar|fan|
|
228
|
-
| 1 | 2 | 3 |
|
229
|
-
| 4 | 5 | 6 |
|
230
|
-
@f_tag
|
231
|
-
Feature: foo
|
232
|
-
Scenario: oh
|
233
|
-
Scenario Outline: outline
|
234
|
-
Scenarios: another
|
235
|
-
|foo|bar|fan|
|
236
|
-
| 1 | 2 | 3 |
|
237
|
-
| 4 | 5 | 6 |
|
238
|
-
Scenarios: yet
|
239
|
-
|foo|bar|fan|
|
240
|
-
| 1 | 2 | 3 |
|
241
|
-
| 4 | 5 | 6 |
|
242
|
-
EOF
|
243
|
-
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
context "1 feature tag, 2 scenario tags, 1 outline tag, 1 example tag" do
|
248
|
-
it "returns 5 tags" do
|
249
|
-
report = one_feature( "fixtures/1_scenario_and_1_outline_with_2_examples/1_feature_tag_2_scenario_tags_1_outline_tag_1_example_tag.feature")
|
250
|
-
report.should == <<EOF
|
251
|
-
@e_tag
|
252
|
-
Feature: foo
|
253
|
-
Scenario Outline: outline
|
254
|
-
Scenarios: yet
|
255
|
-
|foo|bar|fan|
|
256
|
-
| 1 | 2 | 3 |
|
257
|
-
| 4 | 5 | 6 |
|
258
|
-
@f_tag
|
259
|
-
Feature: foo
|
260
|
-
Scenario: oh
|
261
|
-
Scenario Outline: outline
|
262
|
-
Scenarios: another
|
263
|
-
|foo|bar|fan|
|
264
|
-
| 1 | 2 | 3 |
|
265
|
-
| 4 | 5 | 6 |
|
266
|
-
Scenarios: yet
|
267
|
-
|foo|bar|fan|
|
268
|
-
| 1 | 2 | 3 |
|
269
|
-
| 4 | 5 | 6 |
|
270
|
-
@o_tag
|
271
|
-
Feature: foo
|
272
|
-
Scenario Outline: outline
|
273
|
-
Scenarios: another
|
274
|
-
|foo|bar|fan|
|
275
|
-
| 1 | 2 | 3 |
|
276
|
-
| 4 | 5 | 6 |
|
277
|
-
Scenarios: yet
|
278
|
-
|foo|bar|fan|
|
279
|
-
| 1 | 2 | 3 |
|
280
|
-
| 4 | 5 | 6 |
|
281
|
-
@s_tag
|
282
|
-
Feature: foo
|
283
|
-
Scenario: oh
|
284
|
-
@wip
|
285
|
-
Feature: foo
|
286
|
-
Scenario: oh
|
287
|
-
EOF
|
288
|
-
end
|
289
|
-
end
|
290
|
-
|
291
|
-
end
|
292
|
-
|
293
|
-
context "2 outlines 1 scenario" do
|
294
|
-
context "2 outline tags, 1 scenario tag, 1 example tag" do
|
295
|
-
it "returns 4 tags" do
|
296
|
-
report = one_feature( "fixtures/2_outlines_1_scenario/2_outline_tags_1_scenario_tag_1_example_tag.feature")
|
297
|
-
report.should == <<EOF
|
298
|
-
@e_tag
|
299
|
-
Feature: foo
|
300
|
-
Scenario Outline: outline 2
|
301
|
-
Scenarios: yet
|
302
|
-
|foo|bar|fan|
|
303
|
-
| 1 | 2 | 3 |
|
304
|
-
| 4 | 5 | 6 |
|
305
|
-
@s_o_tag_1
|
306
|
-
Feature: foo
|
307
|
-
Scenario Outline: outline 1
|
308
|
-
Scenarios: example
|
309
|
-
|foo|bar|fan|
|
310
|
-
| 1 | 2 | 3 |
|
311
|
-
| 4 | 5 | 6 |
|
312
|
-
@s_o_tag_2
|
313
|
-
Feature: foo
|
314
|
-
Scenario Outline: outline 2
|
315
|
-
Scenarios: another
|
316
|
-
|foo|bar|fan|
|
317
|
-
| 1 | 2 | 3 |
|
318
|
-
| 4 | 5 | 6 |
|
319
|
-
Scenarios: yet
|
320
|
-
|foo|bar|fan|
|
321
|
-
| 1 | 2 | 3 |
|
322
|
-
| 4 | 5 | 6 |
|
323
|
-
@wip
|
324
|
-
Feature: foo
|
325
|
-
Scenario: oh
|
326
|
-
EOF
|
327
|
-
end
|
328
|
-
end
|
329
|
-
|
330
|
-
context "2 outline tags, 2 example tags, 2 empty example names" do
|
331
|
-
it "returns 4 tags" do
|
332
|
-
report = one_feature( "fixtures/2_outlines_1_scenario/empty_example_name.feature")
|
333
|
-
report.should == <<EOF
|
334
|
-
@e_tag
|
335
|
-
Feature: foo
|
336
|
-
Scenario Outline: outline 2
|
337
|
-
Examples:
|
338
|
-
|foo|bar|fan|
|
339
|
-
| 1 | 2 | 3 |
|
340
|
-
| 4 | 5 | 6 |
|
341
|
-
@nameless
|
342
|
-
Feature: foo
|
343
|
-
Scenario Outline: outline 1
|
344
|
-
Scenarios:
|
345
|
-
|foo|bar|fan|
|
346
|
-
| 1 | 2 | 3 |
|
347
|
-
| 4 | 5 | 6 |
|
348
|
-
@s_o_tag_1
|
349
|
-
Feature: foo
|
350
|
-
Scenario Outline: outline 1
|
351
|
-
Scenarios:
|
352
|
-
|foo|bar|fan|
|
353
|
-
| 1 | 2 | 3 |
|
354
|
-
| 4 | 5 | 6 |
|
355
|
-
Scenarios: example set 2
|
356
|
-
|foo|bar|fan|
|
357
|
-
| 5 | 6 | 7 |
|
358
|
-
| 8 | 9 | 0 |
|
359
|
-
@s_o_tag_2
|
360
|
-
Feature: foo
|
361
|
-
Scenario Outline: outline 2
|
362
|
-
Examples:
|
363
|
-
|foo|bar|fan|
|
364
|
-
| 1 | 2 | 3 |
|
365
|
-
| 4 | 5 | 6 |
|
366
|
-
Examples: another
|
367
|
-
|foo|bar|fan|
|
368
|
-
| 1 | 2 | 3 |
|
369
|
-
| 4 | 5 | 6 |
|
370
|
-
EOF
|
371
|
-
end
|
372
|
-
end
|
373
|
-
end
|
374
|
-
|
375
|
-
context "scenario outlines only" do
|
376
|
-
context "3 outlines" do
|
377
|
-
it "includes all outlines" do
|
378
|
-
report = one_feature( "fixtures/3_scenario_outlines.feature")
|
379
|
-
report.should == <<EOF
|
380
|
-
@blocked
|
381
|
-
Feature: foo
|
382
|
-
Scenario Outline: outline 2
|
383
|
-
Scenarios: another
|
384
|
-
|foo|bar|fan|
|
385
|
-
| 1 | 2 | 3 |
|
386
|
-
| 4 | 5 | 6 |
|
387
|
-
@e_tag
|
388
|
-
Feature: foo
|
389
|
-
Scenario Outline: outline 3
|
390
|
-
Scenarios: yet
|
391
|
-
|foo|bar|fan|
|
392
|
-
| 1 | 2 | 3 |
|
393
|
-
| 4 | 5 | 6 |
|
394
|
-
@s_o_tag_1
|
395
|
-
Feature: foo
|
396
|
-
Scenario Outline: outline 1
|
397
|
-
Scenarios: example
|
398
|
-
|foo|bar|fan|
|
399
|
-
| 1 | 2 | 3 |
|
400
|
-
| 4 | 5 | 6 |
|
401
|
-
@s_o_tag_3
|
402
|
-
Feature: foo
|
403
|
-
Scenario Outline: outline 3
|
404
|
-
Scenarios: another
|
405
|
-
|foo|bar|fan|
|
406
|
-
| 1 | 2 | 3 |
|
407
|
-
| 4 | 5 | 6 |
|
408
|
-
Scenarios: yet
|
409
|
-
|foo|bar|fan|
|
410
|
-
| 1 | 2 | 3 |
|
411
|
-
| 4 | 5 | 6 |
|
412
|
-
@wip
|
413
|
-
Feature: foo
|
414
|
-
Scenario Outline: outline 2
|
415
|
-
Scenarios: another
|
416
|
-
|foo|bar|fan|
|
417
|
-
| 1 | 2 | 3 |
|
418
|
-
| 4 | 5 | 6 |
|
419
|
-
Scenarios: yet
|
420
|
-
|foo|bar|fan|
|
421
|
-
| 1 | 2 | 3 |
|
422
|
-
| 4 | 5 | 6 |
|
423
|
-
EOF
|
424
|
-
end
|
425
|
-
end
|
426
|
-
|
427
|
-
end
|
428
|
-
|
429
|
-
end
|
430
|
-
end
|
431
|
-
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Cuporter
|
4
|
-
|
5
|
-
describe "Single Feature Tag Reports" do
|
6
|
-
|
7
|
-
context "empty feature file" do
|
8
|
-
let(:stderr_file) {"stderr.out.txt"}
|
9
|
-
|
10
|
-
before do
|
11
|
-
File.delete(stderr_file) if File.exist?(stderr_file)
|
12
|
-
end
|
13
|
-
|
14
|
-
after do
|
15
|
-
File.delete(stderr_file) if File.exist?(stderr_file)
|
16
|
-
end
|
17
|
-
|
18
|
-
it "returns empty string and should not raise an error" do
|
19
|
-
File.delete(stderr_file) if File.exist?(stderr_file)
|
20
|
-
report = one_feature( "fixtures/empty_file.feature 2> #{stderr_file}")
|
21
|
-
err = File.read(stderr_file)
|
22
|
-
err.should be_empty, err
|
23
|
-
report.should be_empty
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context "one scenario one tag" do
|
28
|
-
it "returns one tag mapped to one scenario name" do
|
29
|
-
report = one_feature( "fixtures/one_scenario_one_tag.feature")
|
30
|
-
report.should == <<EOF
|
31
|
-
@wip
|
32
|
-
Feature: foo
|
33
|
-
Scenario: bar the great foo
|
34
|
-
EOF
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context "one scenario two tags" do
|
39
|
-
it "returns two tags mapped to the same scenario" do
|
40
|
-
report = one_feature( "fixtures/one_scenario_two_tags.feature")
|
41
|
-
report.should == <<EOF
|
42
|
-
@smoke
|
43
|
-
Feature: foo
|
44
|
-
Scenario: some test of something
|
45
|
-
@wip
|
46
|
-
Feature: foo
|
47
|
-
Scenario: some test of something
|
48
|
-
EOF
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context "two scenarios one tag" do
|
53
|
-
it "returns one tag mapped to one scenario" do
|
54
|
-
report = one_feature( "fixtures/two_scenarios_one_tag.feature")
|
55
|
-
report.should == <<EOF
|
56
|
-
@smoke
|
57
|
-
Feature: foo
|
58
|
-
Scenario: another test
|
59
|
-
EOF
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
@@ -1,80 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Cuporter
|
4
|
-
describe NodeNumberer do
|
5
|
-
context '#number' do
|
6
|
-
let(:root) {Node.new("root")}
|
7
|
-
let(:numberer) { NodeNumberer.new}
|
8
|
-
|
9
|
-
before(:each) do
|
10
|
-
root.add_child(Node.new("child_1"))
|
11
|
-
root.add_child(Node.new("child_2"))
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'does not add number to root node' do
|
15
|
-
numberer.number(root)
|
16
|
-
|
17
|
-
root.number.should be_nil
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'adds a number to both children' do
|
21
|
-
numberer.number(root)
|
22
|
-
|
23
|
-
root[:child_1].number.should == 1
|
24
|
-
root[:child_2].number.should == 2
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'does not add a number to children with children' do
|
28
|
-
root[:child_1].add_child(Node.new("grandbaby"))
|
29
|
-
|
30
|
-
numberer.number(root)
|
31
|
-
|
32
|
-
root[:child_1].number.should be_nil
|
33
|
-
root[:child_2].number.should == 2
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'numbers child and grandchild in same sequence' do
|
37
|
-
root[:child_1].add_child(Node.new("grandbaby"))
|
38
|
-
|
39
|
-
numberer.number(root)
|
40
|
-
|
41
|
-
root[:child_1][:grandbaby].number.should == 1
|
42
|
-
root[:child_2].number.should == 2
|
43
|
-
end
|
44
|
-
|
45
|
-
context '2 children, 1 grandchild, and 2 great-grandchildren' do
|
46
|
-
before(:each) do
|
47
|
-
root[:child_2].add_child(Node.new("grandbaby"))
|
48
|
-
root.add_child(Node.new(:child_3))
|
49
|
-
child_4 = Node.new(:child_4)
|
50
|
-
child_4.add_child(Node.new(:grandchild))
|
51
|
-
child_4[:grandchild].add_child(Node.new(:great_grandchild_1))
|
52
|
-
child_4[:grandchild].add_child(Node.new(:great_grandchild_2))
|
53
|
-
root.add_child(child_4)
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'numbers the leaf nodes' do
|
57
|
-
numberer.number(root)
|
58
|
-
|
59
|
-
root.number.should be_nil
|
60
|
-
root[:child_1].number.should == 1
|
61
|
-
root[:child_2].number.should be_nil
|
62
|
-
root[:child_3].number.should == 3
|
63
|
-
root[:child_4].number.should be_nil
|
64
|
-
|
65
|
-
root[:child_2][:grandbaby].number.should == 2
|
66
|
-
root[:child_4][:grandchild].number.should be_nil
|
67
|
-
root[:child_4][:grandchild][:great_grandchild_1].number.should == 4
|
68
|
-
root[:child_4][:grandchild][:great_grandchild_2].number.should == 5
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'keeps total' do
|
72
|
-
numberer.total.should == 0
|
73
|
-
numberer.number(root)
|
74
|
-
numberer.total.should == 5
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
80
|
-
end
|
data/spec/cuporter/node_spec.rb
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Cuporter
|
4
|
-
describe Node do
|
5
|
-
context 'new node' do
|
6
|
-
let(:node) {Node.new("name")}
|
7
|
-
it 'has a name' do
|
8
|
-
node.name.should == "name"
|
9
|
-
end
|
10
|
-
it 'has an empty list of children' do
|
11
|
-
node.should_not have_children
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
context 'children' do
|
16
|
-
let(:node) {Node.new("parent")}
|
17
|
-
it 'can add a child' do
|
18
|
-
child = Node.new("child")
|
19
|
-
node.add_child(child)
|
20
|
-
node.should have_children
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'does not check child type' do
|
24
|
-
expect {
|
25
|
-
node.add_child(:foo)
|
26
|
-
}.to_not raise_error()
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'does not add duplicate' do
|
30
|
-
child = Node.new('child')
|
31
|
-
child.add_child Node.new('grandchild')
|
32
|
-
twin = child.dup
|
33
|
-
|
34
|
-
child.should == twin
|
35
|
-
child.object_id.should_not == twin.object_id
|
36
|
-
|
37
|
-
node.add_child child
|
38
|
-
node.children.size.should == 1
|
39
|
-
|
40
|
-
node.add_child twin
|
41
|
-
node.children.size.should == 1
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
context 'equivalence' do
|
46
|
-
it '== means value equivalence' do
|
47
|
-
n1 = Node.new('herbert')
|
48
|
-
n2 = Node.new('herbert')
|
49
|
-
n1.add_child(Node.new('lou'))
|
50
|
-
n2.add_child(Node.new('lou'))
|
51
|
-
n1.should == n2
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context 'numbering' do
|
56
|
-
let(:node) {Node.new(:node)}
|
57
|
-
it 'can number itself' do
|
58
|
-
expect do
|
59
|
-
node.number_all_descendants
|
60
|
-
end.to_not raise_error()
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'gets a leaf count' do
|
64
|
-
node.number_all_descendants
|
65
|
-
node.total.should == 0
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'can number itself with a child' do
|
69
|
-
node.add_child(Node.new(:child))
|
70
|
-
node.number_all_descendants
|
71
|
-
node.total.should == 1
|
72
|
-
node[:child].number.should == 1
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'can get count from child' do
|
76
|
-
node.add_child(Node.new(:child))
|
77
|
-
node[:child].total.should == 0
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|