rtm 0.1.6 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/DISCLAIMER +10 -33
- data/LICENSE +201 -0
- data/README +32 -3
- data/lib/rtm.rb +126 -74
- data/lib/rtm/axes.rb +298 -0
- data/lib/rtm/axes/association.rb +76 -0
- data/lib/rtm/axes/associations.rb +96 -0
- data/lib/rtm/axes/assocs_names_occs.rb +56 -0
- data/lib/rtm/axes/characteristic.rb +68 -0
- data/lib/rtm/axes/characteristics.rb +93 -0
- data/lib/rtm/axes/string.rb +76 -0
- data/lib/rtm/axes/strings.rb +87 -0
- data/lib/rtm/axes/topic.rb +233 -0
- data/lib/rtm/axes/topics.rb +280 -0
- data/lib/rtm/{backward_compatibility.rb → deprecated/index_property_set.rb} +3 -0
- data/lib/rtm/engine.rb +101 -0
- data/lib/rtm/extensions.rb +65 -5
- data/lib/rtm/{locator_helpers.rb → helpers/locator.rb} +15 -4
- data/lib/rtm/{helpers.rb → helpers/no_output.rb} +3 -0
- data/lib/rtm/helpers/uri.rb +13 -0
- data/lib/rtm/io.rb +19 -0
- data/lib/rtm/io/from_xtm2_libxml.rb +2 -1
- data/lib/rtm/io/tmapix_from.rb +155 -0
- data/lib/rtm/io/tmapix_to.rb +223 -0
- data/lib/rtm/io/to_hash.rb +154 -0
- data/lib/rtm/io/to_jtm.rb +53 -103
- data/lib/rtm/io/to_rdf.rb +45 -0
- data/lib/rtm/io/to_string.rb +21 -8
- data/lib/rtm/io/to_xtm1.rb +6 -4
- data/lib/rtm/io/to_xtm2.rb +10 -8
- data/lib/rtm/io/to_yaml.rb +59 -100
- data/lib/rtm/navigation.rb +23 -0
- data/lib/rtm/navigation/association/players.rb +25 -0
- data/lib/rtm/navigation/name/atomify.rb +19 -0
- data/lib/rtm/navigation/name/characteristics.rb +33 -0
- data/lib/rtm/navigation/occurrence/atomify.rb +19 -0
- data/lib/rtm/navigation/occurrence/characteristics.rb +33 -0
- data/lib/rtm/navigation/topic/characteristics.rb +33 -0
- data/lib/rtm/navigation/topic/indicators.rb +31 -0
- data/lib/rtm/navigation/topic/items.rb +31 -0
- data/lib/rtm/navigation/topic/locators.rb +31 -0
- data/lib/rtm/navigation/topic/players.rb +27 -0
- data/lib/rtm/navigation/topic/supertypes.rb +166 -0
- data/lib/rtm/navigation/topic/traverse.rb +51 -0
- data/lib/rtm/navigation/topic/types.rb +109 -0
- data/lib/rtm/psi.rb +39 -2
- data/lib/rtm/sugar.rb +47 -0
- data/lib/rtm/sugar/association/hash_access.rb +46 -0
- data/lib/rtm/sugar/occurrence/dynamic_value.rb +58 -0
- data/lib/rtm/sugar/occurrence/external.rb +53 -0
- data/lib/rtm/sugar/reifiable/reifier.rb +21 -0
- data/lib/rtm/sugar/role/counterparts.rb +139 -46
- data/lib/rtm/sugar/topic/best_name.rb +74 -0
- data/lib/rtm/sugar/topic/characteristics.rb +126 -12
- data/lib/rtm/sugar/topic/counterparts.rb +145 -10
- data/lib/rtm/sugar/topic/hash_access.rb +140 -30
- data/lib/rtm/sugar/topic/scoped.rb +114 -0
- data/lib/rtm/sugar/topic/topic_ref.rb +86 -0
- data/lib/rtm/sugar/topic/typed.rb +207 -0
- data/lib/rtm/sugar/topic_map/query_cache.rb +66 -0
- data/lib/rtm/sugar/topic_map/themes.rb +53 -0
- data/lib/rtm/sugar/typed/types.rb +38 -0
- data/lib/rtm/validation.rb +7 -4
- data/lib/rtm/version.rb +30 -0
- data/spec/helpers/spec_exampleexamplegroup.rb +14 -0
- data/spec/rtm/axes/association_spec.rb +88 -0
- data/spec/rtm/axes/associations_spec.rb +60 -0
- data/spec/rtm/axes/assocs_names_occs_spec.rb +9 -0
- data/spec/rtm/axes/characteristic_spec.rb +90 -0
- data/spec/rtm/axes/characteristics_spec.rb +85 -0
- data/spec/rtm/axes/string_spec.rb +145 -0
- data/spec/rtm/axes/strings_spec.rb +168 -0
- data/spec/rtm/axes/topic_spec.rb +124 -0
- data/spec/rtm/axes/topics_spec.rb +103 -0
- data/spec/rtm/base_spec.rb +32 -0
- data/spec/rtm/io/tmapix_from_spec.rb +76 -0
- data/spec/rtm/io/tmapix_to_spec.rb +159 -0
- data/spec/rtm/io/to_hash_spec.rb +90 -0
- data/spec/rtm/io/to_rdf_spec.rb +37 -0
- data/spec/rtm/io/to_string_spec.rb +122 -0
- data/spec/rtm/io/to_yaml_spec.rb +89 -0
- data/spec/rtm/navigation/association/players_spec.rb +58 -0
- data/spec/rtm/navigation/association_spec.rb +52 -0
- data/spec/rtm/navigation/name/atomify_spec.rb +27 -0
- data/spec/rtm/navigation/name/characteristics_spec.rb +34 -0
- data/spec/rtm/navigation/name_spec.rb +52 -0
- data/spec/rtm/navigation/occurrence/atomify_spec.rb +27 -0
- data/spec/rtm/navigation/occurrence/characteristics_spec.rb +34 -0
- data/spec/rtm/navigation/occurrence_spec.rb +52 -0
- data/spec/rtm/navigation/string_spec.rb +51 -0
- data/spec/rtm/navigation/topic/characteristics_spec.rb +55 -0
- data/spec/rtm/navigation/topic/indicators_spec.rb +43 -0
- data/spec/rtm/navigation/topic/items_spec.rb +44 -0
- data/spec/rtm/navigation/topic/locators_spec.rb +44 -0
- data/spec/rtm/navigation/topic/players_spec.rb +48 -0
- data/spec/rtm/navigation/topic/scope_spec.rb +41 -0
- data/spec/rtm/navigation/topic/supertypes_spec.rb +376 -0
- data/spec/rtm/navigation/topic/traverse_spec.rb +64 -0
- data/spec/rtm/navigation/topic/types_spec.rb +195 -0
- data/spec/rtm/navigation/topic_spec.rb +153 -0
- data/spec/rtm/sugar/association/hash_access_spec.rb +55 -0
- data/spec/rtm/sugar/occurrence/dynamic_value_spec.rb +171 -0
- data/spec/rtm/sugar/occurrence/external_spec.rb +129 -0
- data/spec/rtm/sugar/reifiable/reifier_spec.rb +41 -0
- data/spec/rtm/sugar/role/counterparts_spec.rb +193 -0
- data/spec/rtm/sugar/topic/best_name_spec.rb +25 -0
- data/spec/rtm/sugar/topic/characteristics_spec.rb +333 -0
- data/spec/rtm/sugar/topic/counterparts_spec.rb +224 -0
- data/spec/rtm/sugar/topic/hash_access_spec.rb +234 -0
- data/spec/rtm/sugar/topic/scoped_spec.rb +195 -0
- data/spec/rtm/sugar/topic/topic_ref_spec.rb +44 -0
- data/spec/rtm/sugar/topic/typed_spec.rb +217 -0
- data/spec/rtm/sugar/topic_map/themes_spec.rb +67 -0
- data/spec/rtm/sugar/typed/types_spec.rb +24 -0
- data/spec/rtm/tmapi/core/association_spec.rb +169 -0
- data/spec/rtm/tmapi/core/construct_spec.rb +25 -0
- data/spec/rtm/tmapi/core/datatype_aware_spec.rb +236 -0
- data/spec/rtm/tmapi/core/name_spec.rb +270 -0
- data/spec/rtm/tmapi/core/occurrence_spec.rb +53 -0
- data/spec/rtm/tmapi/core/reifiable_spec.rb +168 -0
- data/spec/rtm/tmapi/core/role_spec.rb +73 -0
- data/spec/rtm/tmapi/core/scoped_spec.rb +441 -0
- data/spec/rtm/tmapi/core/topic_map_spec.rb +716 -0
- data/spec/rtm/tmapi/core/topic_spec.rb +1468 -0
- data/spec/rtm/tmapi/core/typed_spec.rb +112 -0
- data/spec/rtm/tmapi/core/variant_spec.rb +52 -0
- data/spec/rtm/tmapi/ext/java_util_set_spec.rb +34 -0
- data/spec/rtm/tmapi_spec.rb +44 -0
- data/spec/rtm/utils/sparql_spec.rb +26 -0
- data/spec/rtm_spec.rb +93 -0
- data/spec/spec_helper.rb +28 -0
- data/test/javalibs/junit-4.5.jar +0 -0
- data/test/javalibs/tmapi-2.0-tests.jar +0 -0
- data/test/tmapi_tests.rb +25 -0
- metadata +169 -65
- data/COPYRIGHT +0 -4
- data/lib/Rakefile.rb +0 -42
- data/lib/activetopicmaps.rb +0 -278
- data/lib/rtm/backend/active_record.rb +0 -58
- data/lib/rtm/backend/active_record/001_initial_schema.rb +0 -116
- data/lib/rtm/backend/active_record/association_and_role.rb +0 -33
- data/lib/rtm/backend/active_record/locators.rb +0 -55
- data/lib/rtm/backend/active_record/name_variant_occurrence.rb +0 -45
- data/lib/rtm/backend/active_record/quaaxtm2rtm.rb +0 -113
- data/lib/rtm/backend/active_record/quaaxtm2rtmviews.rb +0 -134
- data/lib/rtm/backend/active_record/set_wrapper.rb +0 -98
- data/lib/rtm/backend/active_record/tm_construct.rb +0 -62
- data/lib/rtm/backend/active_record/tm_delegator.rb +0 -345
- data/lib/rtm/backend/active_record/tm_set_delegator.rb +0 -195
- data/lib/rtm/backend/active_record/tmdm.rb +0 -298
- data/lib/rtm/backend/active_record/topic.rb +0 -87
- data/lib/rtm/backend/active_record/topic_map.rb +0 -314
- data/lib/rtm/backend/active_record/traverse_associations.rb +0 -87
- data/lib/rtm/base.rb +0 -92
- data/lib/rtm/connect.rb +0 -92
- data/lib/rtm/core_ext.rb +0 -6
- data/lib/rtm/io/from_xtm2.rb +0 -263
- data/lib/rtm/merging/merging.rb +0 -307
- data/lib/rtm/pimp_my_api.rb +0 -28
- data/lib/rtm/sugar/topic/identifier_direct.rb +0 -11
- data/lib/rtm/sugar/topic/predefined_associations.rb +0 -42
- data/lib/run_main_project.rb +0 -16
- data/test/base_test.rb +0 -162
@@ -0,0 +1,53 @@
|
|
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::Occurrence
|
7
|
+
|
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 "#parent" do
|
17
|
+
it "should give back the Topic the Occurrence belongs to" do
|
18
|
+
topic = @tm.create_topic_by("House")
|
19
|
+
topic.should be_a_kind_of RTM::Topic
|
20
|
+
@tm.get("House").should be_a_kind_of RTM::Topic
|
21
|
+
testocc = topic.create_occurrence("street number", "1")
|
22
|
+
testocc.should be_a_kind_of RTM::Occurrence
|
23
|
+
testocc.parent.should == topic
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end # of describe self
|
28
|
+
|
29
|
+
describe self do
|
30
|
+
describe "#remove" do
|
31
|
+
before(:each) do
|
32
|
+
@tm = get_used_tm_sys_tm
|
33
|
+
@topic1 = @tm.get!("topic1")
|
34
|
+
@topic2 = @tm.get!("topic2")
|
35
|
+
@occ = @topic1.create_occurrence("birthyear","2000")
|
36
|
+
@topic2.create_occurrence("birthyear","1980")
|
37
|
+
@topic1.should have(1).occurrences
|
38
|
+
@topic1.occurrences.should include @occ
|
39
|
+
end
|
40
|
+
after(:each) do
|
41
|
+
@tm.close
|
42
|
+
end
|
43
|
+
it "should remove this name from the container (topic)" do
|
44
|
+
@tm.literal_index.getOccurrences("2000").size.should == 1
|
45
|
+
@occ.remove
|
46
|
+
@tm.literal_index.getOccurrences("2000").size.should == 0
|
47
|
+
@tm.literal_index.getOccurrences("1980").size.should == 1
|
48
|
+
@topic1.should have(0).occurrences
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end # of describe self
|
52
|
+
|
53
|
+
end # of module
|
@@ -0,0 +1,168 @@
|
|
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::Reifiable
|
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 "#reifier=" do
|
16
|
+
before(:each) do
|
17
|
+
@topic = @tm.get!("test_topic")
|
18
|
+
@a_reifier = @tm.get!("test_reifier")
|
19
|
+
@a_reifier.should be_a_kind_of RTM::Topic
|
20
|
+
@a_reifier["-"] = "since"
|
21
|
+
@a_reifier["date"] = "2009"
|
22
|
+
@locator = @tm.create_locator("test_reifier")
|
23
|
+
@locator.should be_a_kind_of RTM::Locator
|
24
|
+
@name = @topic.create_name("Hans")
|
25
|
+
@name.should be_a_kind_of RTM::Name
|
26
|
+
@name.reifier.should be_nil
|
27
|
+
@variant = @name.create_variant("Hansi",["endearment"])
|
28
|
+
@variant.should be_a_kind_of RTM::Variant
|
29
|
+
@variant.reifier.should be_nil
|
30
|
+
@occ = @topic.create_occurrence("favourite_colour","red")
|
31
|
+
@occ.should be_a_kind_of RTM::Occurrence
|
32
|
+
@assoc = @tm.create_association("mother_child")
|
33
|
+
@assoc.should be_a_kind_of RTM::Association
|
34
|
+
@assoc.reifier.should be_nil
|
35
|
+
@role = @assoc.create_role("child",@topic)
|
36
|
+
@role.should be_a_kind_of RTM::Role
|
37
|
+
@role.reifier.should be_nil
|
38
|
+
end
|
39
|
+
it "should set the reifier if the Construct is a Name and identifier a String" do
|
40
|
+
@name.reifier = "test_reifier"
|
41
|
+
@name.reifier.should == @a_reifier
|
42
|
+
end
|
43
|
+
it "should set the reifier if the Construct is a Name and identifier a Locator" do
|
44
|
+
@name.reifier = @locator
|
45
|
+
@name.reifier.should == @a_reifier
|
46
|
+
end
|
47
|
+
it "should set the reifier if the Construct is a Name and identifier a Topic" do
|
48
|
+
@name.reifier = @a_reifier
|
49
|
+
@name.reifier.should == @a_reifier
|
50
|
+
end
|
51
|
+
it "should set the reifier if the Construct is a Variant and identifier a String" do
|
52
|
+
@variant.reifier = "test_reifier"
|
53
|
+
@variant.reifier.should == @a_reifier
|
54
|
+
end
|
55
|
+
it "should set the reifier if the Construct is a Variant and identifier a Locator" do
|
56
|
+
@variant.reifier = @locator
|
57
|
+
@variant.reifier.should == @a_reifier
|
58
|
+
end
|
59
|
+
it "should set the reifier if the Construct is a Variant and identifier a Topic" do
|
60
|
+
@variant.reifier = @a_reifier
|
61
|
+
@variant.reifier.should == @a_reifier
|
62
|
+
end
|
63
|
+
it "should set the reifier if the Construct is an Occurrence and identifier a String" do
|
64
|
+
@occ.reifier = "test_reifier"
|
65
|
+
@occ.reifier.should == @a_reifier
|
66
|
+
end
|
67
|
+
it "should set the reifier if the Construct is an Occurrence and identifier a Locator" do
|
68
|
+
@occ.reifier = @locator
|
69
|
+
@occ.reifier.should == @a_reifier
|
70
|
+
end
|
71
|
+
it "should set the reifier if the Construct is an Occurrence and identifier a Topic" do
|
72
|
+
@occ.reifier = @a_reifier
|
73
|
+
@occ.reifier.should == @a_reifier
|
74
|
+
end
|
75
|
+
it "should set the reifier if the Construct is an Association and identifier a String" do
|
76
|
+
@assoc.reifier = "test_reifier"
|
77
|
+
@assoc.reifier.should == @a_reifier
|
78
|
+
end
|
79
|
+
it "should set the reifier if the Construct is an Association and identifier a Locator" do
|
80
|
+
@assoc.reifier = @locator
|
81
|
+
@assoc.reifier.should == @a_reifier
|
82
|
+
end
|
83
|
+
it "should set the reifier if the Construct is an Association and identifier a Topic" do
|
84
|
+
@assoc.reifier = @a_reifier
|
85
|
+
@assoc.reifier.should == @a_reifier
|
86
|
+
end
|
87
|
+
it "should set the reifier if the Construct is a Role and identifier a String" do
|
88
|
+
@role.reifier = "test_reifier"
|
89
|
+
@role.reifier.should == @a_reifier
|
90
|
+
end
|
91
|
+
it "should set the reifier if the Construct is a Role and identifier a Locator" do
|
92
|
+
@role.reifier = @locator
|
93
|
+
@role.reifier.should == @a_reifier
|
94
|
+
end
|
95
|
+
it "should set the reifier if the Construct is a Role and identifier a Topic" do
|
96
|
+
@role.reifier = @a_reifier
|
97
|
+
@role.reifier.should == @a_reifier
|
98
|
+
end
|
99
|
+
it "should set the reifier if the Construct is a TopicMap and identifier a String" do
|
100
|
+
@tm.reifier = "test_reifier"
|
101
|
+
@tm.reifier.should == @a_reifier
|
102
|
+
end
|
103
|
+
it "should set the reifier if the Construct is a TopicMap and identifier a Locator" do
|
104
|
+
@tm.reifier = @locator
|
105
|
+
@tm.reifier.should == @a_reifier
|
106
|
+
end
|
107
|
+
it "should set the reifier if the Construct is a TopicMap and identifier a Topic" do
|
108
|
+
@tm.reifier = @a_reifier
|
109
|
+
@tm.reifier.should == @a_reifier
|
110
|
+
end
|
111
|
+
it "should remove a reifier if the identifier is nil or not given" do
|
112
|
+
@name.reifier = "test_reifier"
|
113
|
+
@name.reifier.should == @a_reifier
|
114
|
+
@name.reifier = nil
|
115
|
+
@name.reifier.should be_nil
|
116
|
+
@a_reifier.should have(1).names
|
117
|
+
@occ.reifier = "test_reifier"
|
118
|
+
@occ.reifier.should == @a_reifier
|
119
|
+
@occ.reifier = ()
|
120
|
+
@occ.reifier.should be_nil
|
121
|
+
@variant.reifier = "test_reifier"
|
122
|
+
@variant.reifier.should == @a_reifier
|
123
|
+
@variant.reifier = nil
|
124
|
+
@variant.reifier.should be_nil
|
125
|
+
@assoc.reifier = "test_reifier"
|
126
|
+
@assoc.reifier.should == @a_reifier
|
127
|
+
@assoc.reifier = ()
|
128
|
+
@assoc.reifier.should be_nil
|
129
|
+
@role.reifier = "test_reifier"
|
130
|
+
@role.reifier.should == @a_reifier
|
131
|
+
@role.reifier = nil
|
132
|
+
@role.reifier.should be_nil
|
133
|
+
@tm.reifier = "test_reifier"
|
134
|
+
@tm.reifier.should == @a_reifier
|
135
|
+
@tm.reifier = ()
|
136
|
+
@tm.reifier.should be_nil
|
137
|
+
end
|
138
|
+
it "should raise an error if the identifier referes to a Topic which already reifies another information item" do
|
139
|
+
@name.reifier = "test_reifier"
|
140
|
+
lambda{@occ.reifier = "test_reifier"}.should raise_error
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe "merging of two reifier" do
|
145
|
+
it "should merge two reifier if their reified constructs are merged" do
|
146
|
+
topic = @tm.get!("Hans_Peter")
|
147
|
+
name1 = topic.create_name("Hans")
|
148
|
+
name2 = topic.create_name("Peter")
|
149
|
+
name1.reifier = "ii:reifier1"
|
150
|
+
name2.reifier = "ii:reifier2"
|
151
|
+
name1.reifier.should == @tm.get("ii:reifier1")
|
152
|
+
name2.reifier.should == @tm.get("ii:reifier2")
|
153
|
+
@tm.get("ii:reifier1").should_not == @tm.get!("ii:reifier2")
|
154
|
+
topic.should have(2).names
|
155
|
+
name1.value = "Peter"
|
156
|
+
if implementation_for_spec == :sesametm
|
157
|
+
topic.should have(1).names
|
158
|
+
else
|
159
|
+
pending "cannot automerge unless engine is SesameTM" do
|
160
|
+
topic.should have(1).names
|
161
|
+
end
|
162
|
+
end
|
163
|
+
#puts @basis.tmsf.getFeature("http://tmapi.org/features/automerge")
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
end # of describe self
|
168
|
+
end # of module
|
@@ -0,0 +1,73 @@
|
|
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::Role
|
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 "#parent" do
|
16
|
+
it "should give back the Association to which this Role belongs" do
|
17
|
+
topic = @tm.create_topic_by("Haus")
|
18
|
+
topic.should be_a_kind_of(RTM::Topic)
|
19
|
+
@tm.get("Haus").should be_a_kind_of(RTM::Topic)
|
20
|
+
topic_instance = @tm.create_topic_by("Weisses_Haus")
|
21
|
+
topic_instance.should be_a_kind_of RTM::Topic
|
22
|
+
@tm.get("Weisses_Haus").should be_a_kind_of(RTM::Topic)
|
23
|
+
testassoc = @tm.create_association("Haus-Nummer-Beziehung")
|
24
|
+
testrole = testassoc.create_role(topic, topic_instance) #TMAPI function
|
25
|
+
testassoc.should be_a_kind_of(RTM::Association)
|
26
|
+
testrole.should be_a_kind_of(RTM::Role)
|
27
|
+
testrole.parent.should == testassoc
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#player=" do
|
32
|
+
before(:each) do
|
33
|
+
assoc = @tm.create_association("mother_child")
|
34
|
+
@role = assoc.create_role("child","Hans")
|
35
|
+
@role.should be_a_kind_of RTM::Role
|
36
|
+
end
|
37
|
+
it "should set the player of the Role if identifier is a String" do
|
38
|
+
previous_player = @role.player
|
39
|
+
@role.player = "Tim"
|
40
|
+
@role.player.should_not == previous_player
|
41
|
+
@role.player.should == @tm.get("Tim")
|
42
|
+
end
|
43
|
+
it "should set the player of the Role if identifier is a Locator" do
|
44
|
+
previous_player = @role.player
|
45
|
+
@role.player = @tm.create_locator("Tim")
|
46
|
+
@role.player.should_not == previous_player
|
47
|
+
@role.player.should == @tm.get("Tim")
|
48
|
+
end
|
49
|
+
it "should set the player of the Role if identifier is a Topic" do
|
50
|
+
previous_player = @role.player
|
51
|
+
@role.player = @tm.get!("Tim")
|
52
|
+
@role.player.should_not == previous_player
|
53
|
+
@role.player.should == @tm.get("Tim")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "#remove" do
|
58
|
+
before(:each) do
|
59
|
+
@assoc = @tm.create_association("assoc")
|
60
|
+
@role1 = @assoc.create_role("r1","t1")
|
61
|
+
@role2 = @assoc.create_role("r2","t2")
|
62
|
+
end
|
63
|
+
it "should remove this Role from the container (Association)" do
|
64
|
+
@assoc.should have(2).children
|
65
|
+
@role1.remove
|
66
|
+
@assoc.should have(1).children
|
67
|
+
@role2.remove
|
68
|
+
@assoc.should have(0).children
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end # of describe self
|
73
|
+
end #of module
|
@@ -0,0 +1,441 @@
|
|
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::Scoped
|
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
|
+
describe "#scope" do
|
15
|
+
before(:each) do
|
16
|
+
@topic = @tm.get!("Hans")
|
17
|
+
@name1 = @topic.create_name("Hans")
|
18
|
+
@name2 = @topic.create_name("first", "Hansi", ["home"])
|
19
|
+
@occ1 = @topic.create_occurrence("birthyear","1982")
|
20
|
+
@occ2 = @topic.create_occurrence("birthplace","Berlin",:scope => ["german"])
|
21
|
+
@variant1 = @name1.create_variant("Bubi",["endearment"])
|
22
|
+
@variant2 = @name2.create_variant("Bubi",["home","endearment"])
|
23
|
+
@assoc1 = @tm.create_association("birth")
|
24
|
+
@assoc2 = @tm.create_association("home",["german"])
|
25
|
+
end
|
26
|
+
it "should give back a empty set if no scope is set" do
|
27
|
+
@name1.should have(0).scope
|
28
|
+
@name1.should have(0).themes
|
29
|
+
@occ1.should have(0).scope
|
30
|
+
@occ1.should have(0).themes
|
31
|
+
@assoc1.should have(0).scope
|
32
|
+
@assoc1.should have(0).themes
|
33
|
+
end
|
34
|
+
it "should give back a container" do
|
35
|
+
@name1.scope.should respond_to(:each)
|
36
|
+
@name1.scope.should_not be_a_kind_of String
|
37
|
+
@name2.scope.should respond_to(:each)
|
38
|
+
@name2.scope.should_not be_a_kind_of String
|
39
|
+
@occ1.scope.should respond_to(:each)
|
40
|
+
@occ1.scope.should_not be_a_kind_of String
|
41
|
+
@occ2.scope.should respond_to(:each)
|
42
|
+
@occ2.scope.should_not be_a_kind_of String
|
43
|
+
@variant1.scope.should respond_to(:each)
|
44
|
+
@variant1.scope.should_not be_a_kind_of String
|
45
|
+
@variant2.scope.should respond_to(:each)
|
46
|
+
@variant2.scope.should_not be_a_kind_of String
|
47
|
+
@assoc1.scope.should respond_to(:each)
|
48
|
+
@assoc1.scope.should_not be_a_kind_of String
|
49
|
+
@assoc2.scope.should respond_to(:each)
|
50
|
+
@assoc2.scope.should_not be_a_kind_of String
|
51
|
+
end
|
52
|
+
it "should give back the topics in the scope" do
|
53
|
+
@name2.should have(1).scope
|
54
|
+
@occ2.should have(1).scope
|
55
|
+
@variant2.should have(2).scope
|
56
|
+
@assoc2.should have(1).scope
|
57
|
+
@name2.should have(1).themes
|
58
|
+
@occ2.should have(1).themes
|
59
|
+
@variant2.should have(2).themes
|
60
|
+
@assoc2.should have(1).themes
|
61
|
+
end
|
62
|
+
it "should give back RTM::Topics" do
|
63
|
+
@name2.scope.each{|t| t.should be_a_kind_of RTM::Topic}
|
64
|
+
@occ2.scope.each{|t| t.should be_a_kind_of RTM::Topic}
|
65
|
+
@variant2.scope.each{|t| t.should be_a_kind_of RTM::Topic}
|
66
|
+
@assoc2.scope.each{|t| t.should be_a_kind_of RTM::Topic}
|
67
|
+
end
|
68
|
+
it "should be told, if a theme is in the returned scope or not" do
|
69
|
+
@name2.scope.include?(@tm.get("something"))
|
70
|
+
@occ2.scope.include?(@tm.get("something"))
|
71
|
+
@variant2.scope.include?(@tm.get("something"))
|
72
|
+
@assoc2.scope.include?(@tm.get("something"))
|
73
|
+
###
|
74
|
+
existing_topic = @tm.get!("existing")
|
75
|
+
@name2.scope.should_not include(existing_topic)
|
76
|
+
@occ2.scope.should_not include(existing_topic)
|
77
|
+
@variant2.scope.should_not include(existing_topic)
|
78
|
+
@assoc2.scope.should_not include(existing_topic)
|
79
|
+
###
|
80
|
+
#p @name2.scope.inspect
|
81
|
+
@name2.scope.should include(@tm.get("home"))
|
82
|
+
@occ2.scope.should include(@tm.get("german"))
|
83
|
+
@variant2.scope.should include(@tm.get("endearment"))
|
84
|
+
@assoc2.scope.should include(@tm.get("german"))
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "#add_theme" do
|
89
|
+
before(:each) do
|
90
|
+
@topic = @tm.get!("Hans")
|
91
|
+
@name1 = @topic.create_name("Hans")
|
92
|
+
@name2 = @topic.create_name("first", "Hansi", ["home"])
|
93
|
+
@occ1 = @topic.create_occurrence("birthyear","1982")
|
94
|
+
@occ2 = @topic.create_occurrence("birthplace","Berlin",:scope => ["german"])
|
95
|
+
@variant1 = @name1.create_variant("Bubi",["endearment"])
|
96
|
+
@variant2 = @name2.create_variant("Bubi",["home","endearment"])
|
97
|
+
@assoc1 = @tm.create_association("birth")
|
98
|
+
@assoc2 = @tm.create_association("home",["german"])
|
99
|
+
end
|
100
|
+
it "should add one Topic to the scope of a Name" do
|
101
|
+
@name1.should be_a_kind_of RTM::Name
|
102
|
+
@name2.should be_a_kind_of RTM::Name
|
103
|
+
###
|
104
|
+
@name1.scope.should be_empty
|
105
|
+
@name1.add_theme("test_scope_1")
|
106
|
+
@name1.should have(1).themes
|
107
|
+
@name1.add_theme(@tm.create_locator("test_scope_2"))
|
108
|
+
@name1.should have(2).themes
|
109
|
+
@name1.add_theme(@tm.get!("test_scope_3"))
|
110
|
+
@name1.should have(3).themes
|
111
|
+
@name1.scope.should include @tm.get("test_scope_1"), @tm.get("test_scope_2"), @tm.get("test_scope_3")
|
112
|
+
###
|
113
|
+
@name2.should have(1).themes
|
114
|
+
@name2.scope.should include @tm.get("home")
|
115
|
+
@name2.add_theme("test_scope_1")
|
116
|
+
@name2.should have(2).themes
|
117
|
+
@name2.add_theme(@tm.create_locator("test_scope_2"))
|
118
|
+
@name2.should have(3).themes
|
119
|
+
@name2.add_theme(@tm.get!("test_scope_3"))
|
120
|
+
@name2.should have(4).themes
|
121
|
+
@name2.scope.should include @tm.get("home"), @tm.get("test_scope_1"), @tm.get("test_scope_2"), @tm.get("test_scope_3")
|
122
|
+
end
|
123
|
+
it "should add one Topic to the scope of an Occurrence" do
|
124
|
+
@occ1.should be_a_kind_of RTM::Occurrence
|
125
|
+
@occ2.should be_a_kind_of RTM::Occurrence
|
126
|
+
###
|
127
|
+
@occ1.scope.should be_empty
|
128
|
+
@occ1.add_theme("test_scope_1")
|
129
|
+
@occ1.should have(1).themes
|
130
|
+
@occ1.add_theme(@tm.create_locator("test_scope_2"))
|
131
|
+
@occ1.should have(2).themes
|
132
|
+
@occ1.add_theme(@tm.get!("test_scope_3"))
|
133
|
+
@occ1.should have(3).themes
|
134
|
+
@occ1.scope.should include @tm.get("test_scope_1"), @tm.get("test_scope_2"), @tm.get("test_scope_3")
|
135
|
+
###
|
136
|
+
@occ2.should have(1).themes
|
137
|
+
@occ2.scope.should include @tm.get("german")
|
138
|
+
@occ2.add_theme("test_scope_1")
|
139
|
+
@occ2.should have(2).themes
|
140
|
+
@occ2.add_theme(@tm.create_locator("test_scope_2"))
|
141
|
+
@occ2.should have(3).themes
|
142
|
+
@occ2.add_theme(@tm.get!("test_scope_3"))
|
143
|
+
@occ2.should have(4).themes
|
144
|
+
@occ2.scope.should include @tm.get("german"), @tm.get("test_scope_1"), @tm.get("test_scope_2"), @tm.get("test_scope_3")
|
145
|
+
end
|
146
|
+
it "should add one Topic to the scope of a Variant" do
|
147
|
+
@variant1.should be_a_kind_of RTM::Variant
|
148
|
+
@variant2.should be_a_kind_of RTM::Variant
|
149
|
+
###
|
150
|
+
@variant1.should have(1).themes
|
151
|
+
@variant1.scope.should include @tm.get("endearment")
|
152
|
+
@variant1.add_theme("test_scope_1")
|
153
|
+
@variant1.should have(2).themes
|
154
|
+
@variant1.add_theme(@tm.create_locator("test_scope_2"))
|
155
|
+
@variant1.should have(3).themes
|
156
|
+
@variant1.add_theme(@tm.get!("test_scope_3"))
|
157
|
+
@variant1.should have(4).themes
|
158
|
+
@variant1.scope.should include @tm.get("endearment"), @tm.get("test_scope_1"), @tm.get("test_scope_2"), @tm.get("test_scope_3")
|
159
|
+
###
|
160
|
+
@variant2.should have(2).themes
|
161
|
+
@variant2.scope.should include @tm.get("home"), @tm.get("endearment")
|
162
|
+
@variant2.add_theme("test_scope_1")
|
163
|
+
@variant2.should have(3).themes
|
164
|
+
@variant2.add_theme(@tm.create_locator("test_scope_2"))
|
165
|
+
@variant2.should have(4).themes
|
166
|
+
@variant2.add_theme(@tm.get!("test_scope_3"))
|
167
|
+
@variant2.should have(5).themes
|
168
|
+
@variant2.scope.should include @tm.get("home"), @tm.get("endearment"), @tm.get("test_scope_1"), @tm.get("test_scope_2"), @tm.get("test_scope_3")
|
169
|
+
end
|
170
|
+
it "should add one Topic to the scope of an Association" do
|
171
|
+
@assoc1.should be_a_kind_of RTM::Association
|
172
|
+
@assoc2.should be_a_kind_of RTM::Association
|
173
|
+
###
|
174
|
+
@assoc1.scope.should be_empty
|
175
|
+
@assoc1.add_theme("test_scope_1")
|
176
|
+
@assoc1.should have(1).themes
|
177
|
+
@assoc1.add_theme(@tm.create_locator("test_scope_2"))
|
178
|
+
@assoc1.should have(2).themes
|
179
|
+
@assoc1.add_theme(@tm.get!("test_scope_3"))
|
180
|
+
@assoc1.should have(3).themes
|
181
|
+
@assoc1.scope.should include @tm.get("test_scope_1"), @tm.get("test_scope_2"), @tm.get("test_scope_3")
|
182
|
+
###
|
183
|
+
@assoc2.should have(1).themes
|
184
|
+
@assoc2.scope.should include @tm.get("german")
|
185
|
+
@assoc2.add_theme("test_scope_1")
|
186
|
+
@assoc2.should have(2).themes
|
187
|
+
@assoc2.add_theme(@tm.create_locator("test_scope_2"))
|
188
|
+
@assoc2.should have(3).themes
|
189
|
+
@assoc2.add_theme(@tm.get!("test_scope_3"))
|
190
|
+
@assoc2.should have(4).themes
|
191
|
+
@assoc2.scope.should include @tm.get("german"), @tm.get("test_scope_1"), @tm.get("test_scope_2"), @tm.get("test_scope_3")
|
192
|
+
end
|
193
|
+
it "should raise an error if identifier is not a Topic or Topic-Reference" do
|
194
|
+
lambda{@name1.add_theme(["test_scope"])}.should raise_error
|
195
|
+
lambda{@occ1.add_theme(["test_scope"])}.should raise_error
|
196
|
+
lambda{@variant1.add_theme(["test_scope"])}.should raise_error
|
197
|
+
lambda{@association1.add_theme(["test_scope"])}.should raise_error
|
198
|
+
end
|
199
|
+
it "should raise an error if argument consists of several identifiers" do
|
200
|
+
lambda{@name1.add_theme("testscope1", "testscope2")}.should raise_error
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
describe "#add_themes" do
|
205
|
+
before(:each) do
|
206
|
+
@topic = @tm.get!("Hans")
|
207
|
+
end
|
208
|
+
it "should not add a theme if no argument is given" do
|
209
|
+
@name1 = @topic.create_name("Hans")
|
210
|
+
@name1.should have(0).themes
|
211
|
+
@name1.add_themes()
|
212
|
+
@name1.should have(0).themes
|
213
|
+
###
|
214
|
+
@name2 = @topic.create_name("first", "Hansi", ["home"])
|
215
|
+
@name2.should have(1).themes
|
216
|
+
@name2.add_themes()
|
217
|
+
@name2.should have(1).themes
|
218
|
+
end
|
219
|
+
it "should add one theme if one argument is given" do
|
220
|
+
# adding one
|
221
|
+
@name1 = @topic.create_name("Hans")
|
222
|
+
@name1.should have(0).themes
|
223
|
+
@name1.add_themes("home")
|
224
|
+
@name1.should have(1).themes
|
225
|
+
# adding another
|
226
|
+
@name2 = @topic.create_name("first", "Hansi", ["home"])
|
227
|
+
@name2.should have(1).themes
|
228
|
+
@name2.add_themes("mom")
|
229
|
+
@name2.should have(2).themes
|
230
|
+
# adding t2 again -> should still have 2 themes
|
231
|
+
@name2.add_themes("home")
|
232
|
+
@name2.should have(2).themes
|
233
|
+
end
|
234
|
+
it "should add several themes if several arguments are given" do
|
235
|
+
@name1 = @topic.create_name("Hans")
|
236
|
+
@name1.should have(0).themes
|
237
|
+
@name1.add_themes("home", "mom")
|
238
|
+
@name1.should have(2).themes
|
239
|
+
end
|
240
|
+
it "should add several themes if several arrays with arguments are given" do
|
241
|
+
@name1 = @topic.create_name("Hans")
|
242
|
+
@name1.should have(0).themes
|
243
|
+
@name1.add_themes(["home", "mom"], "testscope")
|
244
|
+
@name1.should have(3).themes
|
245
|
+
end
|
246
|
+
it "should raise an error if a hash is given" do
|
247
|
+
@name1 = @topic.create_name("Hans")
|
248
|
+
@name1.should have(0).themes
|
249
|
+
lambda{@name1.add_themes("x" => "y")}.should raise_error
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
describe "#remove_theme" do
|
254
|
+
before(:each) do
|
255
|
+
@topic = @tm.get!("Hans")
|
256
|
+
@name = @topic.create_name("first", "Hansi", ["home","mom"])
|
257
|
+
@occ = @topic.create_occurrence("birthplace","Berlin",:scope => ["german","english"])
|
258
|
+
@variant = @name.create_variant("Bubi",["endearment"])
|
259
|
+
@assoc = @tm.create_association("home",["german","english"])
|
260
|
+
@existing_dummy = @tm.get!("existing_dummy")
|
261
|
+
end
|
262
|
+
it "should remove a Topic from the scope of a Name" do
|
263
|
+
@name.should be_a_kind_of RTM::Name
|
264
|
+
###
|
265
|
+
@name.should have(2).themes
|
266
|
+
@name.scope.should include @tm.get("home"), @tm.get("mom")
|
267
|
+
@name.remove_theme("home")
|
268
|
+
@name.should have(1).themes
|
269
|
+
@name.scope.should include @tm.get("mom")
|
270
|
+
@name.remove_theme("mom")
|
271
|
+
@name.scope.should be_empty
|
272
|
+
@name.remove_theme("mom")
|
273
|
+
@name.scope.should be_empty
|
274
|
+
end
|
275
|
+
it "should remove a Topic from the scope of an Occurrence" do
|
276
|
+
@occ.should be_a_kind_of RTM::Occurrence
|
277
|
+
###
|
278
|
+
@occ.should have(2).themes
|
279
|
+
@occ.scope.should include @tm.get("german"), @tm.get("english")
|
280
|
+
@occ.remove_theme("german")
|
281
|
+
@occ.should have(1).themes
|
282
|
+
@occ.scope.should include @tm.get("english")
|
283
|
+
@occ.remove_theme("english")
|
284
|
+
@occ.scope.should be_empty
|
285
|
+
@occ.remove_theme("english")
|
286
|
+
@occ.scope.should be_empty
|
287
|
+
end
|
288
|
+
it "should remove a Topic from the scope of a Variant" do
|
289
|
+
@variant.should be_a_kind_of RTM::Variant
|
290
|
+
###
|
291
|
+
@variant.should have(3).themes
|
292
|
+
@variant.scope.should include(@tm.get("home"), @tm.get("mom"), @tm.get("endearment"))
|
293
|
+
@variant.remove_theme("endearment")
|
294
|
+
@variant.should have(2).themes
|
295
|
+
@variant.scope.should include @tm.get("home"), @tm.get("mom")
|
296
|
+
@variant.should be_a_kind_of RTM::Variant
|
297
|
+
end
|
298
|
+
it "should not remove a theme from the scope of an Variant is removed that occurrs in the scope of its parent Name also" do
|
299
|
+
@variant.should be_a_kind_of RTM::Variant
|
300
|
+
###
|
301
|
+
@variant.should have(3).themes
|
302
|
+
@variant.scope.should include(@tm.get("home"), @tm.get("mom"), @tm.get("endearment"))
|
303
|
+
@variant.remove_theme("home")
|
304
|
+
@variant.should have(3).themes
|
305
|
+
@variant.scope.should include(@tm.get("home"), @tm.get("mom"), @tm.get("endearment"))
|
306
|
+
@variant.should be_a_kind_of RTM::Variant
|
307
|
+
end
|
308
|
+
it "should remove a Topic from the scope of an Association" do
|
309
|
+
@assoc.should be_a_kind_of RTM::Association
|
310
|
+
###
|
311
|
+
@assoc.should have(2).themes
|
312
|
+
@assoc.scope.should include @tm.get("german"), @tm.get("english")
|
313
|
+
@assoc.remove_theme("german")
|
314
|
+
@assoc.should have(1).themes
|
315
|
+
@assoc.scope.should include @tm.get("english")
|
316
|
+
@assoc.remove_theme("english")
|
317
|
+
@assoc.scope.should be_empty
|
318
|
+
@assoc.remove_theme("english")
|
319
|
+
@assoc.scope.should be_empty
|
320
|
+
end
|
321
|
+
it "should not fail if the Topic_to_be_removed is not in the scope" do
|
322
|
+
@name.should have(2).themes
|
323
|
+
@name.remove_theme("dummy")
|
324
|
+
@name.remove_theme("existing_dummy")
|
325
|
+
@name.should have(2).themes
|
326
|
+
end
|
327
|
+
it "should raise an error if argument consists of several identifiers" do
|
328
|
+
lambda{@name.remove_theme("testscope1", "testscope2")}.should raise_error
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
describe "#remove_themes" do
|
333
|
+
before(:each) do
|
334
|
+
@topic = @tm.get!("Hans")
|
335
|
+
# @name1 = @topic.create_name("Hans")
|
336
|
+
# @name2 = @topic.create_name("first", "Hansi", ["home"])
|
337
|
+
# @occ1 = @topic.create_occurrence("birthyear","1982")
|
338
|
+
# @occ2 = @topic.create_occurrence("birthplace","Berlin",:scope => ["german"])
|
339
|
+
# @variant1 = @name1.create_variant("Bubi",["endearment"])
|
340
|
+
# @variant2 = @name2.create_variant("Bubi",["home","endearment"])
|
341
|
+
# @assoc1 = @tm.create_association("birth")
|
342
|
+
# @assoc2 = @tm.create_association("home",["german"])
|
343
|
+
end
|
344
|
+
it "should not remove a theme if no argument is given" do
|
345
|
+
@name1 = @topic.create_name("Hans")
|
346
|
+
@name2 = @topic.create_name("first", "Hansi", ["home"])
|
347
|
+
@name1.should have(0).themes
|
348
|
+
@name1.remove_themes()
|
349
|
+
@name1.should have(0).themes
|
350
|
+
@name2.should have(1).themes
|
351
|
+
@name2.remove_themes()
|
352
|
+
@name2.should have(1).themes
|
353
|
+
end
|
354
|
+
it "should remove one theme if one argument is given" do
|
355
|
+
@name2 = @topic.create_name("first", "Hansi", ["home"])
|
356
|
+
@variant2 = @name2.create_variant("Bubi",["home","endearment"])
|
357
|
+
# removing one
|
358
|
+
@variant2.should have(2).themes
|
359
|
+
@variant2.remove_themes("endearment")
|
360
|
+
@variant2.should have(1).themes
|
361
|
+
# removing a non existing
|
362
|
+
@name2 = @topic.create_name("first", "Hansi", ["home"])
|
363
|
+
@name2.should have(1).themes
|
364
|
+
@name2.remove_theme("non_existing")
|
365
|
+
end
|
366
|
+
it "should remove a theme that occurs in a variant also (given a Topic)" do
|
367
|
+
@name2 = @topic.create_name("first", "Hansi", ["home"])
|
368
|
+
@variant2 = @name2.create_variant("Bubi",["home","endearment"])
|
369
|
+
@name2.should have(1).themes
|
370
|
+
@name2.themes.should include(@tm.get("home"))
|
371
|
+
@variant2.should have(2).themes
|
372
|
+
@variant2.themes.should include(@tm.get("home"), @tm.get("endearment"))
|
373
|
+
@name2.remove_theme(@tm.get("home"))
|
374
|
+
@name2.should have(0).themes
|
375
|
+
if implementation_for_spec == :tinytim
|
376
|
+
@variant2.should have(2).themes
|
377
|
+
elsif implementation_for_spec == :ontopia
|
378
|
+
@variant2.should have(1).themes
|
379
|
+
else
|
380
|
+
### ???
|
381
|
+
@variant2.should have(2).themes
|
382
|
+
end
|
383
|
+
end
|
384
|
+
it "should remove a theme that occurs in a variant also" do
|
385
|
+
@name2 = @topic.create_name("first", "Hansi", ["home"])
|
386
|
+
@variant2 = @name2.create_variant("Bubi",["home","endearment"])
|
387
|
+
@name2.should have(1).themes
|
388
|
+
@name2.themes.should include(@tm.get("home"))
|
389
|
+
@variant2.should have(2).themes
|
390
|
+
@variant2.themes.should include(@tm.get("home"), @tm.get("endearment"))
|
391
|
+
@name2.remove_theme("home")
|
392
|
+
@name2.should have(0).themes
|
393
|
+
if implementation_for_spec == :tinytim
|
394
|
+
@variant2.should have(2).themes
|
395
|
+
elsif implementation_for_spec == :ontopia
|
396
|
+
@variant2.should have(1).themes
|
397
|
+
else
|
398
|
+
### ???
|
399
|
+
@variant2.should have(2).themes
|
400
|
+
end
|
401
|
+
end
|
402
|
+
it "should remove several themes if several arguments are given" do
|
403
|
+
@name2 = @topic.create_name("first", "Hansi", ["home","endearment","mom"])
|
404
|
+
@name2.should have(3).themes
|
405
|
+
@name2.remove_themes("home", "mom", "not_existing")
|
406
|
+
@name2.should have(1).themes
|
407
|
+
end
|
408
|
+
it "should remove several themes if several arrays with arguments are given" do
|
409
|
+
@name2 = @topic.create_name("first", "Hansi", ["home","endearment","mom"])
|
410
|
+
@name2.should have(3).themes
|
411
|
+
@name2.remove_themes("home", ["mom", "not_existing"])
|
412
|
+
@name2.should have(1).themes
|
413
|
+
end
|
414
|
+
it "should raise an error if a hash is given" do
|
415
|
+
@name2 = @topic.create_name("first", "Hansi", ["home"])
|
416
|
+
lambda{@name1.remove_themes("x" => "y")}.should raise_error
|
417
|
+
end
|
418
|
+
end
|
419
|
+
|
420
|
+
describe "#scope=" do
|
421
|
+
before(:each) do
|
422
|
+
@topic = @tm.get!("Hans")
|
423
|
+
@name = @topic.create_name("first", "Hansi", ["home","mom"])
|
424
|
+
@occ = @topic.create_occurrence("birthplace","Berlin",:scope => ["german","english"])
|
425
|
+
@variant = @name.create_variant("Bubi",["endearment"])
|
426
|
+
@assoc = @tm.create_association("home",["german","english"])
|
427
|
+
@existing_dummy = @tm.get!("existing_dummy")
|
428
|
+
end
|
429
|
+
it "should set the scope to empty upon request" do
|
430
|
+
@name.should be_a_kind_of RTM::Name
|
431
|
+
@name.should have(2).themes
|
432
|
+
pending
|
433
|
+
@name.scope = []
|
434
|
+
@name.should have(0).themes
|
435
|
+
end
|
436
|
+
end
|
437
|
+
end
|
438
|
+
end
|
439
|
+
|
440
|
+
|
441
|
+
|