cuporter 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,348 @@
1
+ require 'spec_helper'
2
+
3
+ module Cuporter
4
+
5
+ describe "Single Feature Tag Reports" do
6
+
7
+ context "empty feature file" do
8
+ it "returns empty string and should not raise an error" do
9
+ expect do
10
+ @report = one_feature( "fixtures/empty_file.feature")
11
+ end.to_not raise_error()
12
+ @report.should be_empty
13
+ end
14
+ end
15
+
16
+ context "one scenario one tag" do
17
+ it "returns one tag mapped to one scenario name" do
18
+ report = one_feature( "fixtures/one_scenario_one_tag.feature")
19
+ report.should == <<EOF
20
+ @wip
21
+ Feature: foo
22
+ Scenario: bar the great foo
23
+ EOF
24
+ end
25
+ end
26
+
27
+ context "one scenario two tags" do
28
+ it "returns two tags mapped to the same scenario" do
29
+ report = one_feature( "fixtures/one_scenario_two_tags.feature")
30
+ report.should == <<EOF
31
+ @smoke
32
+ Feature: foo
33
+ Scenario: some test of something
34
+ @wip
35
+ Feature: foo
36
+ Scenario: some test of something
37
+ EOF
38
+ end
39
+ end
40
+
41
+ context "two scenarios one tag" do
42
+ it "returns one tag mapped to one scenario" do
43
+ report = one_feature( "fixtures/two_scenarios_one_tag.feature")
44
+ report.should == <<EOF
45
+ @smoke
46
+ Feature: foo
47
+ Scenario: another test
48
+ EOF
49
+ end
50
+ end
51
+
52
+ context "one scenario tag one feature tag" do
53
+ it "returns two tags, one mapped to one scenario, the other mapped to two" do
54
+ report = one_feature( "fixtures/one_scenario_tag_one_feature_tag.feature")
55
+ report.should == <<EOF
56
+ @customer_module
57
+ Feature: foo
58
+ Scenario: another test
59
+ Scenario: some test of something
60
+ @smoke
61
+ Feature: foo
62
+ Scenario: another test
63
+ EOF
64
+ end
65
+ end
66
+
67
+
68
+ context "scenario outline with 2 examples" do
69
+ context "1 example tag" do
70
+ it "returns 1 tag mapped to 1 example" do
71
+ report = one_feature( "fixtures/scenario_outline_with_2_examples/1_example_tag.feature")
72
+ report.should == <<EOF
73
+ @smoke
74
+ Feature: foo
75
+ Scenario Outline: outline
76
+ Scenarios: bang
77
+ EOF
78
+ end
79
+ end
80
+
81
+ context "1 tag per example" do
82
+ it "returns 2 examples mapped to a tag" do
83
+ report = one_feature( "fixtures/scenario_outline_with_2_examples/1_tag_per_example.feature")
84
+ report.should == <<EOF
85
+ @smoke
86
+ Feature: foo
87
+ Scenario Outline: some
88
+ Scenarios: yet
89
+ @wip
90
+ Feature: foo
91
+ Scenario Outline: some
92
+ Scenarios: another
93
+ EOF
94
+ end
95
+ end
96
+
97
+ context "1 tag per example, 2 feature tags" do
98
+ it "returns 4 tags . . ." do
99
+ report = one_feature( "fixtures/scenario_outline_with_2_examples/1_tag_per_example_2_feature_tags.feature")
100
+ report.should == <<EOF
101
+ @smoke
102
+ Feature: foo
103
+ Scenario Outline: outline
104
+ Scenarios: yet
105
+ @taggy
106
+ Feature: foo
107
+ Scenario Outline: outline
108
+ Scenarios: another
109
+ Scenarios: yet
110
+ @waggy
111
+ Feature: foo
112
+ Scenario Outline: outline
113
+ Scenarios: another
114
+ Scenarios: yet
115
+ @wip
116
+ Feature: foo
117
+ Scenario Outline: outline
118
+ Scenarios: another
119
+ EOF
120
+ end
121
+ end
122
+
123
+ context "1 example tag and 1 feature tag" do
124
+ it "returns 2 tags" do
125
+ report = one_feature( "fixtures/scenario_outline_with_2_examples/1_example_tag_and_1_feature_tag.feature")
126
+ report.should == <<EOF
127
+ @f_tag
128
+ Feature: foo
129
+ Scenario Outline: outline
130
+ Scenarios: another
131
+ Scenarios: yet
132
+ @smoke
133
+ Feature: foo
134
+ Scenario Outline: outline
135
+ Scenarios: yet
136
+ EOF
137
+ end
138
+ end
139
+
140
+ context "1 example tag and 1 scenario outline tag" do
141
+ it "returns 1 example mapped to 1 tag" do
142
+ report = one_feature( "fixtures/scenario_outline_with_2_examples/1_example_tag_and_1_scenario_outline_tag.feature")
143
+ report.should == <<EOF
144
+ @s_o_tag
145
+ Feature: foo
146
+ Scenario Outline: outline
147
+ Scenarios: another
148
+ Scenarios: yet
149
+ @smoke
150
+ Feature: foo
151
+ Scenario Outline: outline
152
+ Scenarios: yet
153
+ EOF
154
+ end
155
+ end
156
+ context "1 example tag, 1 scenario outline tag, 1 feature tag" do
157
+ it "3 tags" do
158
+ report = one_feature( "fixtures/scenario_outline_with_2_examples/1_example_tag_1_scenario_outline_tag_1_feature_tag.feature")
159
+ report.should == <<EOF
160
+ @f_tag
161
+ Feature: foo
162
+ Scenario Outline: outline
163
+ Scenarios: another
164
+ Scenarios: yet
165
+ @s_o_tag
166
+ Feature: foo
167
+ Scenario Outline: outline
168
+ Scenarios: another
169
+ Scenarios: yet
170
+ @smoke
171
+ Feature: foo
172
+ Scenario Outline: outline
173
+ Scenarios: yet
174
+ EOF
175
+ end
176
+ end
177
+ end
178
+
179
+ context "1 scenario and 1 outline with 2 examples" do
180
+ context "1 scenario tag, 1 outline tag" do
181
+ it "returns 2 tags, 1 with a scenario, 1 with an outline" do
182
+ report = one_feature( "fixtures/1_scenario_and_1_outline_with_2_examples/1_scenario_tag_1_outline_tag.feature")
183
+ report.should == <<EOF
184
+ @s_o_tag
185
+ Feature: foo
186
+ Scenario Outline: outline
187
+ Scenarios: another
188
+ Scenarios: yet
189
+ @s_tag
190
+ Feature: foo
191
+ Scenario: oh
192
+ EOF
193
+ end
194
+ end
195
+
196
+ context "1 scenario tag, 1 example tag" do
197
+ it "returns 2 tags, 1 with a scenario and 1 with an outline" do
198
+ report = one_feature( "fixtures/1_scenario_and_1_outline_with_2_examples/1_scenario_tag_1_example_tag.feature")
199
+ report.should == <<EOF
200
+ @s_o_tag
201
+ Feature: foo
202
+ Scenario Outline: outline
203
+ Scenarios: another
204
+ @s_tag
205
+ Feature: foo
206
+ Scenario: oh
207
+ EOF
208
+ end
209
+ end
210
+
211
+ context "1 feature tag, 1 example tag" do
212
+ it "returns 2 tags" do
213
+ report = one_feature( "fixtures/1_scenario_and_1_outline_with_2_examples/1_feature_tag_1_example_tag.feature")
214
+ report.should == <<EOF
215
+ @example_tag
216
+ Feature: foo
217
+ Scenario Outline: outline
218
+ Scenarios: another
219
+ @f_tag
220
+ Feature: foo
221
+ Scenario: oh
222
+ Scenario Outline: outline
223
+ Scenarios: another
224
+ Scenarios: yet
225
+ EOF
226
+
227
+ end
228
+ end
229
+
230
+ context "1 feature tag, 2 scenario tags, 1 outline tag, 1 example tag" do
231
+ it "returns 5 tags" do
232
+ 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")
233
+ report.should == <<EOF
234
+ @e_tag
235
+ Feature: foo
236
+ Scenario Outline: outline
237
+ Scenarios: yet
238
+ @f_tag
239
+ Feature: foo
240
+ Scenario: oh
241
+ Scenario Outline: outline
242
+ Scenarios: another
243
+ Scenarios: yet
244
+ @o_tag
245
+ Feature: foo
246
+ Scenario Outline: outline
247
+ Scenarios: another
248
+ Scenarios: yet
249
+ @s_tag
250
+ Feature: foo
251
+ Scenario: oh
252
+ @wip
253
+ Feature: foo
254
+ Scenario: oh
255
+ EOF
256
+ end
257
+ end
258
+
259
+ end
260
+
261
+ context "2 outlines 1 scenario" do
262
+ context "2 outline tags, 1 scenario tag, 1 example tag" do
263
+ it "returns 4 tags" do
264
+ report = one_feature( "fixtures/2_outlines_1_scenario/2_outline_tags_1_scenario_tag_1_example_tag.feature")
265
+ report.should == <<EOF
266
+ @e_tag
267
+ Feature: foo
268
+ Scenario Outline: outline 2
269
+ Scenarios: yet
270
+ @s_o_tag_1
271
+ Feature: foo
272
+ Scenario Outline: outline 1
273
+ Scenarios: example
274
+ @s_o_tag_2
275
+ Feature: foo
276
+ Scenario Outline: outline 2
277
+ Scenarios: another
278
+ Scenarios: yet
279
+ @wip
280
+ Feature: foo
281
+ Scenario: oh
282
+ EOF
283
+ end
284
+ end
285
+
286
+ context "2 outline tags, 2 example tag, 2 empty example names" do
287
+ it "returns 4 tags" do
288
+ report = one_feature( "fixtures/2_outlines_1_scenario/empty_example_name.feature")
289
+ report.should == <<EOF
290
+ @e_tag
291
+ Feature: foo
292
+ Scenario Outline: outline 2
293
+ Examples:
294
+ @nameless
295
+ Feature: foo
296
+ Scenario Outline: outline 1
297
+ Scenarios:
298
+ @s_o_tag_1
299
+ Feature: foo
300
+ Scenario Outline: outline 1
301
+ Scenarios:
302
+ Scenarios: example set 2
303
+ @s_o_tag_2
304
+ Feature: foo
305
+ Scenario Outline: outline 2
306
+ Examples:
307
+ Examples: another
308
+ EOF
309
+ end
310
+ end
311
+ end
312
+
313
+ context "scenario outlines only" do
314
+ context "3 outlines" do
315
+ it "includes all outlines" do
316
+ report = one_feature( "fixtures/3_scenario_outlines.feature")
317
+ report.should == <<EOF
318
+ @blocked
319
+ Feature: foo
320
+ Scenario Outline: outline 2
321
+ Scenarios: another
322
+ @e_tag
323
+ Feature: foo
324
+ Scenario Outline: outline 3
325
+ Scenarios: yet
326
+ @s_o_tag_1
327
+ Feature: foo
328
+ Scenario Outline: outline 1
329
+ Scenarios: example
330
+ @s_o_tag_3
331
+ Feature: foo
332
+ Scenario Outline: outline 3
333
+ Scenarios: another
334
+ Scenarios: yet
335
+ @wip
336
+ Feature: foo
337
+ Scenario Outline: outline 2
338
+ Scenarios: another
339
+ Scenarios: yet
340
+ EOF
341
+ end
342
+ end
343
+
344
+ end
345
+
346
+ end
347
+ end
348
+
@@ -0,0 +1,55 @@
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
+ end
55
+ end
@@ -0,0 +1,10 @@
1
+ module Spec
2
+ module Functional
3
+ module Cli
4
+ def one_feature(path)
5
+ `bin#{File::SEPARATOR}cuporter --input-file #{path}`
6
+ end
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,289 @@
1
+ require 'spec_helper'
2
+
3
+ module Cuporter
4
+ describe TagListNode do
5
+ context 'new tag list node' do
6
+ let(:tag_list_node) {TagListNode.new("name", []) }
7
+ it 'is a node' do
8
+ tag_list_node.should be_a Node
9
+ end
10
+
11
+ it 'has an empty tag list' do
12
+ tag_list_node.should_not have_universal_tags
13
+ end
14
+ context 'with tags' do
15
+ it 'should have tags' do
16
+ tag_list_node = TagListNode.new("name", %w[tag_1 tag_2])
17
+ tag_list_node.should have_universal_tags
18
+ end
19
+ end
20
+ end
21
+
22
+ context 'children' do
23
+ context 'with universal tags but none of their own' do
24
+ it 'child inherits one tag from parent' do
25
+ tag_list_node = TagListNode.new("parent", ["p_tag_1"])
26
+ tag_list_node.add_to_tag_node(Node.new("child"))
27
+
28
+ tag_list_node.children.size.should == 1
29
+ tag_list_node.children.first.name.should == "p_tag_1"
30
+
31
+ tag_list_node[:p_tag_1].children.size.should == 1
32
+ tag_list_node[:p_tag_1].children.first.name.should == "child"
33
+
34
+ end
35
+ it 'child inherits 2 tags from parent' do
36
+ tag_list_node = TagListNode.new("parent", ["p_tag_1", "p_tag_2"])
37
+ tag_list_node.add_to_tag_node(Node.new("child"))
38
+
39
+ tag_list_node.children.size.should == 2
40
+ tag_list_node.children.first.name.should == "p_tag_1"
41
+ tag_list_node.children.last.name.should == "p_tag_2"
42
+
43
+ tag_list_node[:p_tag_1].children.size.should == 1
44
+ tag_list_node[:p_tag_1].children.first.name.should == "child"
45
+
46
+ tag_list_node[:p_tag_2].children.size.should == 1
47
+ tag_list_node[:p_tag_2].children.first.name.should == "child"
48
+
49
+ end
50
+ end
51
+ context 'without universal tags but some of their own' do
52
+ let(:tag_list_node) {TagListNode.new("parent", []) }
53
+ it 'child has one tag' do
54
+ tag_list_node.add_to_tag_node(Node.new("child"), ["c_tag_1"])
55
+
56
+ tag_list_node.children.size.should == 1
57
+ tag_list_node.children.first.name.should == "c_tag_1"
58
+
59
+ tag_list_node[:c_tag_1].children.size.should == 1
60
+ tag_list_node[:c_tag_1].children.first.name.should == "child"
61
+ end
62
+ it 'child has two tags' do
63
+ tag_list_node.add_to_tag_node(Node.new("child"), ["c_tag_1", "c_tag_2"])
64
+
65
+ tag_list_node.children.size.should == 2
66
+ tag_list_node.children.first.name.should == "c_tag_1"
67
+ tag_list_node.children.last.name.should == "c_tag_2"
68
+
69
+ tag_list_node[:c_tag_1].children.size.should == 1
70
+ tag_list_node[:c_tag_1].children.first.name.should == "child"
71
+
72
+ tag_list_node[:c_tag_2].children.size.should == 1
73
+ tag_list_node[:c_tag_2].children.first.name.should == "child"
74
+ end
75
+ end
76
+ context 'with universal tags and their own tags' do
77
+ let(:tag_list_node) {TagListNode.new("parent",%w[p_tag_1 p_tag_2]) }
78
+ it "2 universal tags and 2 child tags" do
79
+ tag_list_node.add_to_tag_node(Node.new("child"), ["c_tag_1", "c_tag_2"])
80
+
81
+ tag_list_node.children.size.should == 4
82
+ tag_list_node.children.collect do |c|
83
+ c.name
84
+ end.should == %w[p_tag_1 p_tag_2 c_tag_1 c_tag_2]
85
+
86
+ tag_list_node[:p_tag_1].children.size.should == 1
87
+ tag_list_node[:p_tag_1].children.first.name.should == "child"
88
+
89
+ tag_list_node[:p_tag_2].children.size.should == 1
90
+ tag_list_node[:p_tag_2].children.first.name.should == "child"
91
+
92
+ tag_list_node[:c_tag_1].children.size.should == 1
93
+ tag_list_node[:c_tag_1].children.first.name.should == "child"
94
+
95
+ tag_list_node[:c_tag_2].children.size.should == 1
96
+ tag_list_node[:c_tag_2].children.first.name.should == "child"
97
+ end
98
+ end
99
+ context 'with no tags at all' do
100
+ it 'top node has no children' do
101
+ tag_list_node = TagListNode.new("parent", [])
102
+ tag_list_node.add_to_tag_node(Node.new("child"))
103
+
104
+ tag_list_node.should_not have_children
105
+
106
+ end
107
+
108
+ end
109
+
110
+ context 'second child with preexisting tag' do
111
+ it 'top node has 1 child and 2 grandchildren' do
112
+ tag_list_node = TagListNode.new("parent", ["p_tag_1"])
113
+ tag_list_node.add_to_tag_node(Node.new("child_1"))
114
+ tag_list_node.add_to_tag_node(Node.new("child_2"))
115
+
116
+ tag_list_node.children.size.should == 1
117
+ tag_list_node.children[0].name.should == "p_tag_1"
118
+
119
+ tag_list_node[:p_tag_1].children.size.should == 2
120
+ tag_list_node[:p_tag_1].children[0].name.should == "child_1"
121
+ tag_list_node[:p_tag_1].children[1].name.should == "child_2"
122
+ end
123
+
124
+ it '2 child nodes with 1 universal tag and 2 child tags' do
125
+ tag_list_node = TagListNode.new("parent", ["p_tag_1"])
126
+ tag_list_node.add_to_tag_node(Node.new("child_1"), ["c_tag_1"])
127
+ tag_list_node.add_to_tag_node(Node.new("child_2"), ["c_tag_1", "c_tag_2"])
128
+
129
+ tag_list_node.children.size.should == 3
130
+ tag_list_node.children[0].name.should == "p_tag_1"
131
+ tag_list_node.children[1].name.should == "c_tag_1"
132
+ tag_list_node.children[2].name.should == "c_tag_2"
133
+
134
+ tag_list_node[:p_tag_1].children.size.should == 2
135
+ tag_list_node[:p_tag_1].children[0].name.should == "child_1"
136
+ tag_list_node[:p_tag_1].children[1].name.should == "child_2"
137
+
138
+ tag_list_node[:c_tag_1].children.size.should == 2
139
+ tag_list_node[:c_tag_1].children[0].name.should == "child_1"
140
+ tag_list_node[:c_tag_1].children[1].name.should == "child_2"
141
+
142
+ tag_list_node[:c_tag_2].children.size.should == 1
143
+ tag_list_node[:c_tag_2].children[0].name.should == "child_2"
144
+ end
145
+ end
146
+
147
+ context 'child is tag list node' do
148
+ context '1 universal tag on parent and no universal tags on child' do
149
+ context "child must be initialized with parent's universal tags" do
150
+ it 'top node has no children' do
151
+ p = TagListNode.new("parent", ["p_tag_1"])
152
+ c = TagListNode.new("child", [] )
153
+ c.add_to_tag_node(Node.new("leaf_1"))
154
+
155
+ p.should_not have_children
156
+ end
157
+
158
+ it 'all leaf nodes are under parent universal tag' do
159
+ p = TagListNode.new("parent", ["p_tag_1"])
160
+ c = TagListNode.new("child", p.universal_tags)
161
+ c.add_to_tag_node(Node.new("leaf_1"))
162
+ c.add_to_tag_node(Node.new("leaf_2"))
163
+ p.merge(c)
164
+
165
+ p.children.size.should == 1
166
+ p.children[0].name.should == "p_tag_1"
167
+
168
+ p[:p_tag_1].children.size.should == 1
169
+ p[:p_tag_1].children[0].name.should == "child"
170
+
171
+ p[:p_tag_1][:child].children.size.should == 2
172
+ p[:p_tag_1][:child].children[0].name.should == "leaf_1"
173
+ p[:p_tag_1][:child].children[1].name.should == "leaf_2"
174
+
175
+ p[:p_tag_1][:child][:leaf_1].should_not have_children
176
+ p[:p_tag_1][:child][:leaf_2].should_not have_children
177
+ end
178
+ end
179
+ end
180
+
181
+ context '1 universal tag on parent and 1 universal tag on child' do
182
+ it "2 tags have 2 leaf nodes" do
183
+ p = TagListNode.new("parent", ["p_tag_1"])
184
+ c = TagListNode.new("child", p.universal_tags | ["c_tag_1"])
185
+ c.add_to_tag_node(Node.new("leaf_1"))
186
+ c.add_to_tag_node(Node.new("leaf_2"))
187
+ p.merge(c)
188
+
189
+ p.children.size.should == 2
190
+ p.children[0].name.should == "p_tag_1"
191
+ p.children[1].name.should == "c_tag_1"
192
+ p[:p_tag_1].children.size.should == 1
193
+ p[:p_tag_1].children[0].name.should == "child"
194
+ p[:c_tag_1].children.size.should == 1
195
+ p[:c_tag_1].children[0].name.should == "child"
196
+
197
+ p[:p_tag_1][:child].children.size.should == 2
198
+ p[:p_tag_1][:child].children[0].name.should == "leaf_1"
199
+ p[:p_tag_1][:child].children[1].name.should == "leaf_2"
200
+
201
+ p[:c_tag_1][:child].children.size.should == 2
202
+ p[:c_tag_1][:child].children[0].name.should == "leaf_1"
203
+ p[:c_tag_1][:child].children[1].name.should == "leaf_2"
204
+
205
+ p[:p_tag_1][:child][:leaf_1].should_not have_children
206
+ p[:p_tag_1][:child][:leaf_2].should_not have_children
207
+
208
+ p[:c_tag_1][:child][:leaf_1].should_not have_children
209
+ p[:c_tag_1][:child][:leaf_2].should_not have_children
210
+ end
211
+ end
212
+
213
+ context '1 universal tag on parent and 1 tag on 1 leaf' do
214
+ it "1 tag has 1 leaf node, the other has 2 leaf nodes" do
215
+ p = TagListNode.new("parent", ["p_tag_1"])
216
+ c = TagListNode.new("child", p.universal_tags )
217
+ c.add_to_tag_node(Node.new("leaf_1"))
218
+ c.add_to_tag_node(Node.new("leaf_2"), ["l_tag_1"])
219
+ p.merge(c)
220
+
221
+ p.children.size.should == 2
222
+ p.children[0].name.should == "p_tag_1"
223
+ p.children[1].name.should == "l_tag_1"
224
+ p[:p_tag_1].children.size.should == 1
225
+ p[:p_tag_1].children[0].name.should == "child"
226
+ p[:l_tag_1].children.size.should == 1
227
+ p[:l_tag_1].children[0].name.should == "child"
228
+
229
+ p[:p_tag_1][:child].children.size.should == 2
230
+ p[:p_tag_1][:child].children[0].name.should == "leaf_1"
231
+ p[:p_tag_1][:child].children[1].name.should == "leaf_2"
232
+
233
+ p[:l_tag_1][:child].children.size.should == 1
234
+ p[:l_tag_1][:child].children[0].name.should == "leaf_2"
235
+
236
+ p[:p_tag_1][:child][:leaf_1].should_not have_children
237
+ p[:p_tag_1][:child][:leaf_2].should_not have_children
238
+
239
+ p[:l_tag_1][:child][:leaf_2].should_not have_children
240
+ end
241
+ end
242
+
243
+ context '1 universal tag on parent 1 universal tag on child 1 tag on leaf' do
244
+ it "2 tags with 2 leaves, 1 tag with 1 leaf" do
245
+ p = TagListNode.new("parent", ["p_tag_1"])
246
+ c = TagListNode.new("child", p.universal_tags | ["c_tag_1"])
247
+ c.add_to_tag_node(Node.new("leaf_1"))
248
+ c.add_to_tag_node(Node.new("leaf_2"), ["l_tag_1"])
249
+ p.merge(c)
250
+
251
+ p.children.size.should == 3
252
+ p.children[0].name.should == "p_tag_1"
253
+ p.children[1].name.should == "c_tag_1"
254
+ p.children[2].name.should == "l_tag_1"
255
+
256
+ p[:p_tag_1].children.size.should == 1
257
+ p[:p_tag_1].children[0].name.should == "child"
258
+
259
+ p[:c_tag_1].children.size.should == 1
260
+ p[:c_tag_1].children[0].name.should == "child"
261
+
262
+ p[:l_tag_1].children.size.should == 1
263
+ p[:l_tag_1].children[0].name.should == "child"
264
+
265
+ p[:p_tag_1][:child].children.size.should == 2
266
+ p[:p_tag_1][:child].children[0].name.should == "leaf_1"
267
+ p[:p_tag_1][:child].children[1].name.should == "leaf_2"
268
+
269
+ p[:c_tag_1][:child].children.size.should == 2
270
+ p[:c_tag_1][:child].children[0].name.should == "leaf_1"
271
+ p[:c_tag_1][:child].children[1].name.should == "leaf_2"
272
+
273
+ p[:l_tag_1][:child].children.size.should == 1
274
+ p[:l_tag_1][:child].children[0].name.should == "leaf_2"
275
+
276
+ p[:p_tag_1][:child][:leaf_1].should_not have_children
277
+ p[:p_tag_1][:child][:leaf_2].should_not have_children
278
+
279
+ p[:c_tag_1][:child][:leaf_1].should_not have_children
280
+ p[:c_tag_1][:child][:leaf_2].should_not have_children
281
+
282
+ p[:l_tag_1][:child][:leaf_2].should_not have_children
283
+ end
284
+ end
285
+ end
286
+ end
287
+
288
+ end
289
+ end