rtm 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/README +38 -3
  2. data/lib/rtm.rb +25 -47
  3. data/lib/rtm/axes.rb +7 -4
  4. data/lib/rtm/axes/association.rb +1 -1
  5. data/lib/rtm/axes/associations.rb +1 -1
  6. data/lib/rtm/axes/characteristic.rb +1 -1
  7. data/lib/rtm/axes/characteristics.rb +1 -1
  8. data/lib/rtm/axes/topic.rb +3 -3
  9. data/lib/rtm/axes/topics.rb +3 -3
  10. data/lib/rtm/engine.rb +48 -5
  11. data/lib/rtm/extensions.rb +58 -8
  12. data/lib/rtm/io.rb +2 -1
  13. data/lib/rtm/io/tmapix_from.rb +155 -0
  14. data/lib/rtm/io/tmapix_to.rb +223 -0
  15. data/lib/rtm/io/to_hash.rb +79 -41
  16. data/lib/rtm/io/to_jtm.rb +1 -1
  17. data/lib/rtm/io/to_rdf.rb +20 -5
  18. data/lib/rtm/io/to_string.rb +13 -2
  19. data/lib/rtm/io/to_yaml.rb +39 -11
  20. data/lib/rtm/navigation.rb +1 -15
  21. data/lib/rtm/navigation/association/players.rb +1 -1
  22. data/lib/rtm/navigation/name/characteristics.rb +1 -1
  23. data/lib/rtm/navigation/occurrence/characteristics.rb +1 -1
  24. data/lib/rtm/navigation/topic/characteristics.rb +1 -1
  25. data/lib/rtm/navigation/topic/players.rb +1 -1
  26. data/lib/rtm/navigation/topic/supertypes.rb +21 -17
  27. data/lib/rtm/navigation/topic/traverse.rb +1 -1
  28. data/lib/rtm/navigation/topic/types.rb +6 -4
  29. data/lib/rtm/psi.rb +6 -0
  30. data/lib/rtm/sugar.rb +42 -29
  31. data/lib/rtm/sugar/association/hash_access.rb +3 -3
  32. data/lib/rtm/sugar/occurrence/dynamic_value.rb +39 -56
  33. data/lib/rtm/sugar/occurrence/external.rb +53 -0
  34. data/lib/rtm/sugar/reifiable/reifier.rb +21 -0
  35. data/lib/rtm/sugar/role/counterparts.rb +12 -6
  36. data/lib/rtm/sugar/topic/best_name.rb +74 -0
  37. data/lib/rtm/sugar/topic/characteristics.rb +10 -10
  38. data/lib/rtm/sugar/topic/counterparts.rb +131 -119
  39. data/lib/rtm/sugar/topic/scoped.rb +102 -53
  40. data/lib/rtm/sugar/topic/topic_ref.rb +63 -12
  41. data/lib/rtm/sugar/topic/typed.rb +50 -2
  42. data/lib/rtm/sugar/topic_map/query_cache.rb +66 -0
  43. data/lib/rtm/sugar/topic_map/themes.rb +53 -0
  44. data/lib/rtm/sugar/typed/types.rb +1 -1
  45. data/lib/rtm/validation.rb +2 -2
  46. data/lib/rtm/version.rb +18 -6
  47. data/spec/rtm/axes/string_spec.rb +7 -7
  48. data/spec/rtm/axes/strings_spec.rb +10 -10
  49. data/spec/rtm/io/tmapix_from_spec.rb +76 -0
  50. data/spec/rtm/io/tmapix_to_spec.rb +159 -0
  51. data/spec/rtm/io/to_hash_spec.rb +90 -0
  52. data/spec/rtm/io/to_rdf_spec.rb +37 -0
  53. data/spec/rtm/io/to_string_spec.rb +122 -0
  54. data/spec/rtm/io/to_yaml_spec.rb +89 -0
  55. data/spec/rtm/sugar/occurrence/dynamic_value_spec.rb +156 -1
  56. data/spec/rtm/sugar/occurrence/external_spec.rb +129 -0
  57. data/spec/rtm/sugar/reifiable/reifier_spec.rb +41 -0
  58. data/spec/rtm/sugar/role/counterparts_spec.rb +174 -172
  59. data/spec/rtm/sugar/topic/best_name_spec.rb +25 -0
  60. data/spec/rtm/sugar/topic/characteristics_spec.rb +20 -5
  61. data/spec/rtm/sugar/topic/counterparts_spec.rb +41 -1
  62. data/spec/rtm/sugar/topic/hash_access_spec.rb +1 -1
  63. data/spec/rtm/sugar/topic/scoped_spec.rb +178 -114
  64. data/spec/rtm/sugar/topic/topic_ref_spec.rb +10 -10
  65. data/spec/rtm/sugar/topic/typed_spec.rb +196 -134
  66. data/spec/rtm/sugar/topic_map/themes_spec.rb +67 -0
  67. data/spec/rtm/sugar/typed/types_spec.rb +1 -1
  68. data/spec/rtm/tmapi/core/association_spec.rb +2 -2
  69. data/spec/rtm/tmapi/core/datatype_aware_spec.rb +236 -0
  70. data/spec/rtm/tmapi/core/name_spec.rb +186 -1
  71. data/spec/rtm/tmapi/core/occurrence_spec.rb +24 -67
  72. data/spec/rtm/tmapi/core/reifiable_spec.rb +2 -2
  73. data/spec/rtm/tmapi/core/scoped_spec.rb +40 -2
  74. data/spec/rtm/tmapi/core/topic_map_spec.rb +98 -30
  75. data/spec/rtm/tmapi/core/topic_spec.rb +558 -82
  76. data/spec/rtm/tmapi/core/variant_spec.rb +3 -3
  77. data/spec/rtm_spec.rb +0 -1
  78. data/spec/spec_helper.rb +7 -2
  79. data/test/javalibs/junit-4.5.jar +0 -0
  80. data/test/javalibs/tmapi-2.0-tests.jar +0 -0
  81. data/test/tmapi_tests.rb +25 -0
  82. metadata +66 -11
  83. data/lib/rtm/io/ontopia_io.rb +0 -25
  84. data/lib/rtm/io/tmapix.rb +0 -234
  85. data/lib/rtm/sugar/occurrence/externalize.rb +0 -31
  86. data/spec/rtm/io/tmapix_spec.rb +0 -85
  87. data/test/base_unit_test.rb +0 -161
  88. data/test/base_unit_test_tmapi.rb +0 -165
@@ -0,0 +1,41 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ require File.dirname(__FILE__) + '/../../../spec_helper'
5
+
6
+ module RTM::Sugar::Reifiable
7
+ module Reifier
8
+ describe self do
9
+ before(:each) do
10
+ @tm = get_used_tm_sys_tm
11
+ end
12
+ after(:each) do
13
+ @tm.close
14
+ end
15
+
16
+ describe "#reifier!" do
17
+ it "should not return nil if the Reifiable has no reifier" do
18
+ @tm.reifier.should be_nil
19
+ @tm.reifier!.should_not be_nil
20
+ end
21
+ it "should return the reifier if the Reifiable has a reifier" do
22
+ @tm.get("reifier_for_tm").should be_nil
23
+ @tm.reifier = "reifier_for_tm"
24
+ @tm.get("reifier_for_tm").should_not be_nil
25
+ @tm.reifier!.should == @tm.get("reifier_for_tm")
26
+ end
27
+ it "should create a topic as reifier for the Reifiable otherwise" do
28
+ topic1 = @tm.create_topic
29
+ @tm.should have(1).topics
30
+ @tm.reifier.should be_nil
31
+ result = @tm.reifier!
32
+ result.should be_a_kind_of(RTM::Topic)
33
+ @tm.should have(2).topics
34
+ @tm.topics.should include(topic1, result)
35
+ @tm.reifier.should == result
36
+ end
37
+ end
38
+
39
+ end
40
+ end
41
+ end
@@ -3,189 +3,191 @@
3
3
 
4
4
  require File.dirname(__FILE__) + '/../../../spec_helper'
5
5
 
6
- module Sugar
7
- module Role
8
- module Counterparts
9
- describe self do
10
- before(:each) do
11
- @tm = get_used_tm_sys_tm
12
- @t1,@t2,@t3,@t4,@t5 = @tm.get!(["t1","t2","t3","t4","t5"])
13
- @t_a1,@t_a2,@t_a3 = @tm.get!(["t_a1","t_a2","t_a3"])
14
- @t_r1,@t_r2,@t_r3,@t_r4,@t_r5 = @tm.get!(["t_r1","t_r2","t_r3","t_r4","t_r5"])
15
- @a1 = @tm.create_association(@t_a1)
16
- @a2 = @tm.create_association(@t_a2)
17
- @a3 = @tm.create_association(@t_a1)
18
- @a4 = @tm.create_association(@t_a3)
19
- @a5 = @tm.create_association(@t_a1)
20
- @r1 = @a1.create_role(@t_r1, @t1)
21
- @r2 = @a1.create_role(@t_r2, @t2)
22
- @r3 = @a1.create_role(@t_r1, @t4)
23
- @r4 = @a2.create_role(@t_r1, @t1)
24
- @r5 = @a2.create_role(@t_r3, @t3)
25
- @r6 = @a3.create_role(@t_r4, @t1)
26
- @r7 = @a3.create_role(@t_r5, @t5)
27
- @r8 = @a4.create_role(@t_r4, @t4)
28
- @r9 = @a4.create_role(@t_r5, @t4)
29
- @r10= @a5.create_role(@t_r2, @t5)
30
- end
31
- after(:each) do
32
- @tm.close
6
+ module RTM::Sugar::Role
7
+ module Counterparts
8
+ describe self do
9
+ before(:each) do
10
+ @tm = get_used_tm_sys_tm
11
+ @t1,@t2,@t3,@t4,@t5 = @tm.get!(["t1","t2","t3","t4","t5"])
12
+ @t_a1,@t_a2,@t_a3 = @tm.get!(["t_a1","t_a2","t_a3"])
13
+ @t_r1,@t_r2,@t_r3,@t_r4,@t_r5 = @tm.get!(["t_r1","t_r2","t_r3","t_r4","t_r5"])
14
+ @a1 = @tm.create_association(@t_a1)
15
+ @a2 = @tm.create_association(@t_a2)
16
+ @a3 = @tm.create_association(@t_a1)
17
+ @a4 = @tm.create_association(@t_a3)
18
+ @a5 = @tm.create_association(@t_a1)
19
+ @r1 = @a1.create_role(@t_r1, @t1)
20
+ @r2 = @a1.create_role(@t_r2, @t2)
21
+ @r3 = @a1.create_role(@t_r1, @t4)
22
+ @r4 = @a2.create_role(@t_r1, @t1)
23
+ @r5 = @a2.create_role(@t_r3, @t3)
24
+ @r6 = @a3.create_role(@t_r4, @t1)
25
+ @r7 = @a3.create_role(@t_r5, @t5)
26
+ @r8 = @a4.create_role(@t_r4, @t4)
27
+ @r9 = @a4.create_role(@t_r5, @t4)
28
+ @r10= @a5.create_role(@t_r2, @t5)
29
+ end
30
+ after(:each) do
31
+ @tm.close
32
+ end
33
+
34
+ describe "#counterparts" do
35
+ it "should give back all counterparts (roles) if no otype is given" do
36
+ @r1.should have(2).counterparts
37
+ @r1.counterparts.should include @r2, @r3
38
+ @r8.should have(1).counterparts
39
+ @r8.counterparts.should include @r9
40
+ end
41
+ it "should give back some counterparts (roles) if otype is given" do
42
+ @r1.counterparts(:otype=>@t_r1).size.should == 1
43
+ @r1.counterparts(:otype=>@t_r1).should include @r3
44
+ @r6.counterparts(:otype=>@t_r1).should be_empty
33
45
  end
46
+ end
34
47
 
35
- describe "#counterparts" do
36
- it "should give back all counterparts (roles) if no otype is given" do
37
- @r1.should have(2).counterparts
38
- @r1.counterparts.should include @r2, @r3
39
- @r8.should have(1).counterparts
40
- @r8.counterparts.should include @r9
41
- end
42
- it "should give back some counterparts (roles) if otype is given" do
43
- @r1.counterparts(:otype=>@t_r1).size.should == 1
44
- @r1.counterparts(:otype=>@t_r1).should include @r3
45
- @r6.counterparts(:otype=>@t_r1).should be_empty
46
- end
47
- end
48
- describe "#counterplayers" do
49
- it "should give back all counterplayers (topics) if no otype is given" do
50
- @r1.should have(2).counterplayers
51
- @r1.counterplayers.should include @t2, @t4
52
- @r8.should have(1).counterplayers
53
- @r8.counterplayers.should include @t4
54
- end
55
- it "should give back some counterplayers (topics) if otype is given " do
56
- @r1.counterplayers(:otype=>@t_r1).size.should == 1
57
- @r1.counterplayers(:otype=>@t_r1).should include @t4
58
- @r4.counterplayers(:otype=>@t_r2).size.should == 0
59
- end
60
- end
61
- describe "#counterpart" do
62
- it "should give back the counterpart Role if the parent association is binary" do
63
- @r4.counterpart.should == @r5
64
- @r5.counterpart.should == @r4
65
- end
66
- it "should raise an error if the üparent association includes more than 2 roles" do
67
- lambda {@r2.counterpart}.should raise_error
68
- end
69
- it "should give back nil if the parent association is unary" do
70
- @r10.counterpart.should be_nil
71
- end
72
- end
73
- describe "#counterplayer" do
74
- it "should give back the counterplayer Topic if the parent association is binary" do
75
- @r6.counterplayer.should == @t5
76
- @r5.counterplayer.should == @t1
77
- end
78
- it "should raise an error if the parent association includes more than 2 roles" do
79
- lambda {@r2.counterplayer}.should raise_error
80
- end
81
- it "should give back nil if the parent association is unary" do
82
- @r10.counterplayer.should be_nil
83
- end
48
+ describe "#counterplayers" do
49
+ it "should give back all counterplayers (topics) if no otype is given" do
50
+ @r1.should have(2).counterplayers
51
+ @r1.counterplayers.should include @t2, @t4
52
+ @r8.should have(1).counterplayers
53
+ @r8.counterplayers.should include @t4
54
+ end
55
+ it "should give back some counterplayers (topics) if otype is given " do
56
+ @r1.counterplayers(:otype=>@t_r1).size.should == 1
57
+ @r1.counterplayers(:otype=>@t_r1).should include @t4
58
+ @r4.counterplayers(:otype=>@t_r2).size.should == 0
84
59
  end
85
60
  end
86
61
 
87
- describe self do
88
- before(:each) do
89
- @tm = get_used_tm_sys_tm
90
- t1,t2,t3,t4,t5,t6,t7,t8 = @tm.get!(["t1","t2","t3","t4","t5","t6","t7","t8"])
91
- t_a1,t_a2 = @tm.get!(["t_a1","t_a2"])
92
- @t_r1,@t_r2,@t_r3,@t_r4,@t_r5,@t_r6 = @tm.get!(["t_r1","t_r2","t_r3","t_r4","t_r5","t_r6"])
93
- a1 = @tm.create_association(t_a1)
94
- a2 = @tm.create_association(t_a1)
95
- a3 = @tm.create_association(t_a1)
96
- a4 = @tm.create_association(t_a1)
97
- a5 = @tm.create_association(t_a1)
98
- a6 = @tm.create_association(t_a2)
99
- @r1 = a1.create_role(@t_r1, t1)
100
- @r2 = a1.create_role(@t_r3, t2)
101
- @r4 = a2.create_role(@t_r1, t1)
102
- @r5 = a2.create_role(@t_r3, t3)
103
- @r6 = a3.create_role(@t_r1, t1)
104
- @r7 = a3.create_role(@t_r5, t5)
105
- @r3 = a4.create_role(@t_r1, t1)
106
- @r8 = a4.create_role(@t_r3, t4)
107
- @r9 = a4.create_role(@t_r6, t6)
108
- @r10 = a5.create_role(@t_r4, t1)
109
- @r11 = a5.create_role(@t_r3, t7)
110
- @r12 = a6.create_role(@t_r4,t1)
111
- @r13 = a6.create_role(@t_r2,t8)
112
- end
113
- after(:each) do
114
- @tm.close
115
- end
116
- describe "#peers" do
117
- it "should give back roles of other associations (with same size and atype) that have the same rtype and otype" do
118
- @r5.peers.size.should == 1
119
- @r5.peers.should include @r2
120
- @r5.peers(:arity => :stuff, :otype => :stuff, :atype => :stuff, :rtyoe => :stuff).should == @r5.peers
121
- end
122
- it "should give back roles of other associations (with any size but same atype) that have the same rtype and otype" do
123
- @r5.peers(:arity => :loose).size.should == 2
124
- @r5.peers(:arity => :loose).should include @r2
125
- @r5.peers(:arity => :loose).should include @r8
126
- end
127
- it "should give back roles of other associations (with same size and atype) that have the same otype but not rtype" do
128
- @r5.peers(:rtype => :loose).size.should == 2
129
- @r5.peers(:rtype => :loose).should include @r2,@r7
130
- end
131
- it "should give back roles of other associations (with any size but same atype) that have the same otype but not rtype" do
132
- @r5.peers(:arity => :loose, :rtype => :loose).size.should == 4
133
- @r5.peers(:arity => :loose, :rtype => :loose).should include @r2,@r7,@r8,@r9
134
- end
135
- it "should give back roles of other associations (with same size and atype) that have any otype but same rtype" do
136
- @r5.peers(:otype => :loose).size.should == 2
137
- @r5.peers(:otype => :loose).should include @r2,@r11
138
- end
139
- it "should give back roles of other associations (with same size but any atype) that have any otype and rtype" do
140
- @r5.peers(:atype => :loose, :otype => :loose, :rtype => :loose).size == 4
141
- @r5.peers(:atype => :loose, :otype => :loose, :rtype => :loose).should include @r7,@r13,@r2,@r11
142
- end
143
- it "should raise an error if argument is not a Hash" do
144
- lambda{@r5.peers("something")}.should raise_error
145
- end
62
+ describe "#counterpart" do
63
+ it "should give back the counterpart Role if the parent association is binary" do
64
+ @r4.counterpart.should == @r5
65
+ @r5.counterpart.should == @r4
66
+ end
67
+ it "should raise an error if the üparent association includes more than 2 roles" do
68
+ lambda {@r2.counterpart}.should raise_error
69
+ end
70
+ it "should give back nil if the parent association is unary" do
71
+ @r10.counterpart.should be_nil
146
72
  end
147
73
  end
148
74
 
149
- describe self do
150
- before(:each) do
151
- @tm = get_used_tm_sys_tm
152
- @dad1 = @tm.get!("dad1")
153
- @dad2 = @tm.get!("dad2")
154
- @mom1 = @tm.get!("mom1")
155
- @mom2 = @tm.fet!("mom2")
156
- @kid1 = @tm.get!("kid1")
157
- @kid2 = @tm.get!("kid2")
158
- @kid3 = @tm.get!("kid3")
159
- @kid4 = @tm.get!("kid4")
160
- @pk = @tm.get!("parent_kid")
161
- @mr = @tm.get!("mom_role")
162
- @dr = @tm.get!("dad_role")
163
- @kr = @tm.get!("kid_role")
164
- @assoc1 = @tm.create_association(@pk)
165
- @r_a1_k1 = @assoc1.create_role(@kr,@kid1)
166
- @r_a1_m1 = @assoc1.create_role(@mr,@mom1)
167
- @r_a1_d1 = @assoc1.create_role(@dr,@dad1)
168
- @assoc2 = @tm.create_association(@pk)
169
- @r_a2_k2 = @assoc2.create_role(@kr,@kid2)
170
- @r_a2_m1 = @assoc2.create_role(@mr,@mom1)
171
- @r_a2_d1 = @assoc2.create_role(@dr,@dad1)
172
- @assoc3 = @tm.create_association(@pk)
173
- @r_a3_k3 = @assoc3.create_role(@kr,@kid3)
174
- @r_a3_m2 = @assoc3.create_role(@mr,@mom2)
175
- @r_a3_d1 = @assoc3.create_role(@dr,@dad1)
176
- @assoc4 = @tm.create_association(@pk)
177
- @r_a4_k4 = @assoc4.create_role(@kr,@kid4)
178
- @r_a4_m1 = @assoc4.create_role(@mr,@mom1)
179
- @r_a4_d2 = @assoc4.create_role(@dr,@dad2)
180
- end
181
- after(:each) do
182
- @tm.close
183
- end
184
- describe "#peers the second time" do
185
-
75
+ describe "#counterplayer" do
76
+ it "should give back the counterplayer Topic if the parent association is binary" do
77
+ @r6.counterplayer.should == @t5
78
+ @r5.counterplayer.should == @t1
79
+ end
80
+ it "should raise an error if the parent association includes more than 2 roles" do
81
+ lambda {@r2.counterplayer}.should raise_error
82
+ end
83
+ it "should give back nil if the parent association is unary" do
84
+ @r10.counterplayer.should be_nil
85
+ end
86
+ end
87
+ end
88
+
89
+ describe self do
90
+ before(:each) do
91
+ @tm = get_used_tm_sys_tm
92
+ t1,t2,t3,t4,t5,t6,t7,t8 = @tm.get!(["t1","t2","t3","t4","t5","t6","t7","t8"])
93
+ t_a1,t_a2 = @tm.get!(["t_a1","t_a2"])
94
+ @t_r1,@t_r2,@t_r3,@t_r4,@t_r5,@t_r6 = @tm.get!(["t_r1","t_r2","t_r3","t_r4","t_r5","t_r6"])
95
+ a1 = @tm.create_association(t_a1)
96
+ a2 = @tm.create_association(t_a1)
97
+ a3 = @tm.create_association(t_a1)
98
+ a4 = @tm.create_association(t_a1)
99
+ a5 = @tm.create_association(t_a1)
100
+ a6 = @tm.create_association(t_a2)
101
+ @r1 = a1.create_role(@t_r1, t1)
102
+ @r2 = a1.create_role(@t_r3, t2)
103
+ @r4 = a2.create_role(@t_r1, t1)
104
+ @r5 = a2.create_role(@t_r3, t3)
105
+ @r6 = a3.create_role(@t_r1, t1)
106
+ @r7 = a3.create_role(@t_r5, t5)
107
+ @r3 = a4.create_role(@t_r1, t1)
108
+ @r8 = a4.create_role(@t_r3, t4)
109
+ @r9 = a4.create_role(@t_r6, t6)
110
+ @r10 = a5.create_role(@t_r4, t1)
111
+ @r11 = a5.create_role(@t_r3, t7)
112
+ @r12 = a6.create_role(@t_r4,t1)
113
+ @r13 = a6.create_role(@t_r2,t8)
114
+ end
115
+ after(:each) do
116
+ @tm.close
117
+ end
118
+
119
+ describe "#peers" do
120
+ it "should give back roles of other associations (with same size and atype) that have the same rtype and otype" do
121
+ @r5.peers.size.should == 1
122
+ @r5.peers.should include @r2
123
+ @r5.peers(:arity => :stuff, :otype => :stuff, :atype => :stuff, :rtyoe => :stuff).should == @r5.peers
124
+ end
125
+ it "should give back roles of other associations (with any size but same atype) that have the same rtype and otype" do
126
+ @r5.peers(:arity => :loose).size.should == 2
127
+ @r5.peers(:arity => :loose).should include @r2
128
+ @r5.peers(:arity => :loose).should include @r8
129
+ end
130
+ it "should give back roles of other associations (with same size and atype) that have the same otype but not rtype" do
131
+ @r5.peers(:rtype => :loose).size.should == 2
132
+ @r5.peers(:rtype => :loose).should include @r2,@r7
133
+ end
134
+ it "should give back roles of other associations (with any size but same atype) that have the same otype but not rtype" do
135
+ @r5.peers(:arity => :loose, :rtype => :loose).size.should == 4
136
+ @r5.peers(:arity => :loose, :rtype => :loose).should include @r2,@r7,@r8,@r9
137
+ end
138
+ it "should give back roles of other associations (with same size and atype) that have any otype but same rtype" do
139
+ @r5.peers(:otype => :loose).size.should == 2
140
+ @r5.peers(:otype => :loose).should include @r2,@r11
141
+ end
142
+ it "should give back roles of other associations (with same size but any atype) that have any otype and rtype" do
143
+ @r5.peers(:atype => :loose, :otype => :loose, :rtype => :loose).size == 4
144
+ @r5.peers(:atype => :loose, :otype => :loose, :rtype => :loose).should include @r7,@r13,@r2,@r11
145
+ end
146
+ it "should raise an error if argument is not a Hash" do
147
+ lambda{@r5.peers("something")}.should raise_error
186
148
  end
187
149
  end
150
+ end
188
151
 
152
+ describe self do
153
+ before(:each) do
154
+ @tm = get_used_tm_sys_tm
155
+ @dad1 = @tm.get!("dad1")
156
+ @dad2 = @tm.get!("dad2")
157
+ @mom1 = @tm.get!("mom1")
158
+ @mom2 = @tm.fet!("mom2")
159
+ @kid1 = @tm.get!("kid1")
160
+ @kid2 = @tm.get!("kid2")
161
+ @kid3 = @tm.get!("kid3")
162
+ @kid4 = @tm.get!("kid4")
163
+ @pk = @tm.get!("parent_kid")
164
+ @mr = @tm.get!("mom_role")
165
+ @dr = @tm.get!("dad_role")
166
+ @kr = @tm.get!("kid_role")
167
+ @assoc1 = @tm.create_association(@pk)
168
+ @r_a1_k1 = @assoc1.create_role(@kr,@kid1)
169
+ @r_a1_m1 = @assoc1.create_role(@mr,@mom1)
170
+ @r_a1_d1 = @assoc1.create_role(@dr,@dad1)
171
+ @assoc2 = @tm.create_association(@pk)
172
+ @r_a2_k2 = @assoc2.create_role(@kr,@kid2)
173
+ @r_a2_m1 = @assoc2.create_role(@mr,@mom1)
174
+ @r_a2_d1 = @assoc2.create_role(@dr,@dad1)
175
+ @assoc3 = @tm.create_association(@pk)
176
+ @r_a3_k3 = @assoc3.create_role(@kr,@kid3)
177
+ @r_a3_m2 = @assoc3.create_role(@mr,@mom2)
178
+ @r_a3_d1 = @assoc3.create_role(@dr,@dad1)
179
+ @assoc4 = @tm.create_association(@pk)
180
+ @r_a4_k4 = @assoc4.create_role(@kr,@kid4)
181
+ @r_a4_m1 = @assoc4.create_role(@mr,@mom1)
182
+ @r_a4_d2 = @assoc4.create_role(@dr,@dad2)
183
+ end
184
+ after(:each) do
185
+ @tm.close
186
+ end
187
+ describe "#peers the second time" do
188
+
189
+ end
189
190
  end
191
+
190
192
  end
191
193
  end
@@ -0,0 +1,25 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ require File.dirname(__FILE__) + '/../../../spec_helper'
5
+
6
+ module RTM::Sugar::Topic::BestName
7
+ describe self do
8
+ before(:each) do
9
+ @tm = get_used_tm_sys_tm
10
+ end
11
+ after(:each) do
12
+ @tm.close
13
+ end
14
+
15
+ describe "#best_name" do
16
+ before(:each) do
17
+ @topic = @tm.get!("Leipzig")
18
+ end
19
+ it "should return a String" do
20
+ @topic.best_name.should be_a_kind_of String
21
+ #puts @topic.best_name
22
+ end
23
+ end
24
+ end
25
+ end
@@ -3,7 +3,7 @@
3
3
 
4
4
  require File.dirname(__FILE__) + '/../../../spec_helper'
5
5
 
6
- module Sugar::Topic::Characteristics
6
+ module RTM::Sugar::Topic::Characteristics
7
7
  describe self do
8
8
  before(:each) do
9
9
  @tm = get_used_tm_sys_tm
@@ -17,7 +17,7 @@ module Sugar::Topic::Characteristics
17
17
  @uni_leipzig = @tm.get!("Uni_LE")
18
18
  @occ1 = @uni_leipzig.create_occurrence("Alter","600")
19
19
  @occ2 = @uni_leipzig.create_occurrence("Heimat","Sachsen")
20
- @occ3 = @uni_leipzig.create_occurrence("Webseite",@tm.create_locator("http://www.uni-leipzig.de"))
20
+ @occ3 = @uni_leipzig.create_occurrence("Webseite",@tm.create_locator("http://www.example.org/uni-leipzig"))
21
21
  end
22
22
  it "should give back all occurrences that are not of Datatype AnyURI" do
23
23
  @uni_leipzig.internal_occurrences.size.should == 2
@@ -31,7 +31,7 @@ module Sugar::Topic::Characteristics
31
31
  @uni_leipzig = @tm.get!("Uni_LE")
32
32
  @occ1 = @uni_leipzig.create_occurrence("Alter","600")
33
33
  @occ2 = @uni_leipzig.create_occurrence("Heimat","Sachsen")
34
- @occ3 = @uni_leipzig.create_occurrence("Webseite",@tm.create_locator("http://www.uni-leipzig.de"))
34
+ @occ3 = @uni_leipzig.create_occurrence("Webseite",@tm.create_locator("http://www.example.org/uni-leipzig"))
35
35
  end
36
36
  it "should give back all occurrences that are of Datatype AnyURI" do
37
37
  @uni_leipzig.external_occurrences.size.should == 1
@@ -155,10 +155,18 @@ module Sugar::Topic::Characteristics
155
155
  @topic.names_by(:scope => ["mum","dummy"]).size.should == 2
156
156
  @topic.names_by(:scope => ["mum","dummy"]).should include @name3, @name5
157
157
  end
158
- it "should give back no names if a scope is given which is not a String, Locator or Topic" do
158
+ it "should give back no names if a scope is given which is not a String, Locator or Topic" do
159
159
  lambda{topic.names_by(:scope => 1)}.should raise_error
160
160
  lambda{@topic.names_by(:scope => [1])}.should raise_error
161
161
  end
162
+ it "should give back some names if scope is set to :ucs" do
163
+ @topic.names_by(:scope => :ucs).size.should == 2
164
+ @topic.names_by(:scope => :ucs).should include(@name1, @name2)
165
+ end
166
+ it "should give back some names (in the unconstrained scope) if scope is []" do
167
+ @topic.names_by(:scope => []).size.should == 2
168
+ @topic.names_by(:scope => []).should include(@name1, @name2)
169
+ end
162
170
  it "should not give back a name several times if several equal themes are given" do
163
171
  @topic.names_by(:scope => ["official","official"]).should == @topic.names_by(:scope => "official")
164
172
  end
@@ -289,7 +297,14 @@ module Sugar::Topic::Characteristics
289
297
  it "should not give back an occurrence several times if several equal themes are given" do
290
298
  @topic.occurrences_by(:scope => ["2009","2009"]).should == @topic.occurrences_by(:scope => "2009")
291
299
  end
292
- it "should give back occurrences in the unconstrained scope if scope equals :ucs"
300
+ it "should give back some occurrences (in the unconstrained scope) if scope is set to :ucs" do
301
+ @topic.occurrences_by(:scope => :ucs).size.should == 2
302
+ @topic.occurrences_by(:scope => :ucs).should include(@occ1, @occ2)
303
+ end
304
+ it "should give back some occurrences (in the unconstrained scope) if scope is []" do
305
+ @topic.occurrences_by(:scope => []).size.should == 2
306
+ @topic.occurrences_by(:scope => []).should include(@occ1, @occ2)
307
+ end
293
308
  it "should test datatype"
294
309
  it "should not create Topics" do
295
310
  @tm.get("dummy1").should be_nil