activefacts-api 0.9.3 → 0.9.4
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/TODO +16 -0
- data/VERSION +1 -1
- data/activefacts-api.gemspec +4 -2
- data/lib/activefacts/api/constellation.rb +118 -50
- data/lib/activefacts/api/date.rb +98 -0
- data/lib/activefacts/api/entity.rb +198 -206
- data/lib/activefacts/api/exceptions.rb +19 -4
- data/lib/activefacts/api/guid.rb +4 -13
- data/lib/activefacts/api/instance.rb +55 -93
- data/lib/activefacts/api/instance_index.rb +1 -32
- data/lib/activefacts/api/numeric.rb +51 -55
- data/lib/activefacts/api/object_type.rb +155 -151
- data/lib/activefacts/api/role.rb +3 -32
- data/lib/activefacts/api/standard_types.rb +8 -4
- data/lib/activefacts/api/support.rb +0 -22
- data/lib/activefacts/api/value.rb +62 -39
- data/lib/activefacts/tracer.rb +8 -6
- data/spec/constellation/constellation_spec.rb +150 -80
- data/spec/constellation/instance_spec.rb +97 -73
- data/spec/fact_type/role_values_spec.rb +33 -12
- data/spec/fact_type/roles_spec.rb +4 -28
- data/spec/identification_scheme/identification_spec.rb +1 -0
- data/spec/identification_scheme/identity_change_spec.rb +4 -4
- data/spec/metadata_spec.rb +269 -0
- data/spec/object_type/entity_type/multipart_identification_spec.rb +1 -2
- data/spec/object_type/value_type/autocounter_spec.rb +4 -4
- data/spec/object_type/value_type/date_time_spec.rb +1 -1
- data/spec/object_type/value_type/guid_spec.rb +3 -3
- data/spec/object_type/value_type/value_type_spec.rb +2 -1
- data/spec/simplecov_helper.rb +3 -2
- metadata +5 -3
@@ -3,8 +3,14 @@
|
|
3
3
|
# Copyright (c) 2008 Clifford Heath. Read the LICENSE file.
|
4
4
|
#
|
5
5
|
|
6
|
+
#require 'ruby-debug'; Debugger.start
|
7
|
+
#trap "INT" do
|
8
|
+
# puts caller*"\n\t"
|
9
|
+
# debugger
|
10
|
+
#end
|
11
|
+
|
6
12
|
describe "An instance of every type of ObjectType" do
|
7
|
-
before :
|
13
|
+
before :all do
|
8
14
|
Object.send :remove_const, :Mod if Object.const_defined?("Mod")
|
9
15
|
module Mod
|
10
16
|
# These are the base value types we're going to test:
|
@@ -84,6 +90,8 @@ describe "An instance of every type of ObjectType" do
|
|
84
90
|
end
|
85
91
|
end
|
86
92
|
|
93
|
+
@constellation = ActiveFacts::API::Constellation.new(Mod)
|
94
|
+
|
87
95
|
# Simple Values
|
88
96
|
@int = 0
|
89
97
|
@real = 0.0
|
@@ -96,76 +104,86 @@ describe "An instance of every type of ObjectType" do
|
|
96
104
|
@guid = '01234567-89ab-cdef-0123-456789abcdef'
|
97
105
|
|
98
106
|
# Value Type instances
|
99
|
-
@int_value =
|
100
|
-
@real_value =
|
101
|
-
@auto_counter_value =
|
102
|
-
@new_auto_counter_value =
|
103
|
-
@string_value =
|
104
|
-
@date_value =
|
107
|
+
@int_value = @constellation.IntVal(1)
|
108
|
+
@real_value = @constellation.RealVal(1.0)
|
109
|
+
@auto_counter_value = @constellation.AutoCounterVal(1)
|
110
|
+
@new_auto_counter_value = @constellation.AutoCounterVal(:new)
|
111
|
+
@string_value = @constellation.StringVal("one")
|
112
|
+
@date_value = @constellation.DateVal(2008, 04, 20)
|
105
113
|
# Parse the date:
|
106
|
-
@date_value =
|
114
|
+
@date_value = @constellation.DateVal('2nd Nov 2001')
|
107
115
|
d = ::Date.civil(2008, 04, 20)
|
108
|
-
@date_time_value = Mod::DateTimeVal.
|
116
|
+
@date_time_value = Mod::DateTimeVal.civil(2008, 04, 20, 10, 28, 14)
|
109
117
|
# This next isn't in the same pattern; it makes a Decimal from a BigDecimal rather than a String (coverage reasons)
|
110
|
-
@decimal_value =
|
111
|
-
@guid_value =
|
118
|
+
@decimal_value = @constellation.DecimalVal(BigDecimal.new('98765432109876543210'))
|
119
|
+
@guid_value = @constellation.GuidVal(:new)
|
120
|
+
@guid_as_value = @constellation.GuidVal(@guid)
|
112
121
|
|
113
122
|
# Value SubType instances
|
114
|
-
@int_sub_value =
|
115
|
-
@real_sub_value =
|
116
|
-
@auto_counter_sub_value =
|
117
|
-
@auto_counter_sub_value_new =
|
118
|
-
@string_sub_value =
|
119
|
-
@date_sub_value =
|
120
|
-
@date_time_sub_value =
|
123
|
+
@int_sub_value = @constellation.IntSubVal(4)
|
124
|
+
@real_sub_value = @constellation.RealSubVal(4.0)
|
125
|
+
@auto_counter_sub_value = @constellation.AutoCounterSubVal(4)
|
126
|
+
@auto_counter_sub_value_new = @constellation.AutoCounterSubVal(:new)
|
127
|
+
@string_sub_value = @constellation.StringSubVal("five")
|
128
|
+
@date_sub_value = @constellation.DateSubVal(2008, 04, 25)
|
129
|
+
@date_time_sub_value = @constellation.DateTimeSubVal(::DateTime.civil(2008, 04, 26, 10, 28, 14))
|
121
130
|
# This next isn't in the same pattern; it makes a Decimal from a BigNum rather than a String (coverage reasons)
|
122
|
-
@decimal_sub_value =
|
123
|
-
@guid_sub_value =
|
131
|
+
@decimal_sub_value = @constellation.DecimalSubVal(98765432109876543210)
|
132
|
+
@guid_sub_value = @constellation.GuidSubVal(:new)
|
124
133
|
|
125
134
|
# Entities identified by Value Type, SubType and Entity-by-value-type instances
|
126
|
-
@test_by_int =
|
127
|
-
@test_by_real =
|
128
|
-
@test_by_auto_counter =
|
129
|
-
@test_by_auto_counter_new =
|
130
|
-
@test_by_string =
|
131
|
-
@test_by_date =
|
132
|
-
#@test_by_date =
|
135
|
+
@test_by_int = @constellation.TestByInt(2)
|
136
|
+
@test_by_real = @constellation.TestByReal(2.0)
|
137
|
+
@test_by_auto_counter = @constellation.TestByAutoCounter(2)
|
138
|
+
@test_by_auto_counter_new = @constellation.TestByAutoCounter(:new)
|
139
|
+
@test_by_string = @constellation.TestByString("two")
|
140
|
+
@test_by_date = @constellation.TestByDate(Date.civil(2008,04,28))
|
141
|
+
#@test_by_date = @constellation.TestByDate(2008,04,28)
|
142
|
+
# Array packing/unpacking obfuscates the following case
|
143
|
+
# @test_by_date_time = @constellation.TestByDateTime([2008,04,28,10,28,15])
|
144
|
+
# Pass an array of values directly to DateTime.civil:
|
145
|
+
@test_by_date_time = @constellation.TestByDateTime(@date_time_value)
|
146
|
+
#@test_by_date_time = @constellation.TestByDateTime(DateTime.civil(2008,04,28,10,28,15))
|
147
|
+
@test_by_decimal = @constellation.TestByDecimal('98765432109876543210')
|
148
|
+
|
149
|
+
@test_by_guid = @constellation.TestByGuid(@guid)
|
150
|
+
@constellation.TestByGuid[[@guid_as_value]].should_not be_nil
|
151
|
+
|
152
|
+
@test_by_int_sub = @constellation.TestByIntSub(2)
|
153
|
+
@test_by_real_sub = @constellation.TestByRealSub(5.0)
|
154
|
+
@test_by_auto_counter_sub = @constellation.TestByAutoCounterSub(6)
|
155
|
+
@test_by_auto_counter_new_sub = @constellation.TestByAutoCounterSub(:new)
|
156
|
+
@test_by_string_sub = @constellation.TestByStringSub("six")
|
157
|
+
@test_by_date_sub = @constellation.TestByDateSub(Date.civil(2008,04,27))
|
158
|
+
# Array packing/unpacking obfuscates the following case
|
159
|
+
# @test_by_date_time_sub = @constellation.TestByDateTimeSub([2008,04,29,10,28,15])
|
133
160
|
# Pass an array of values directly to DateTime.civil:
|
134
|
-
@
|
135
|
-
|
136
|
-
@
|
137
|
-
|
138
|
-
|
139
|
-
@
|
140
|
-
@
|
141
|
-
@
|
142
|
-
@
|
143
|
-
@
|
144
|
-
@
|
145
|
-
@
|
146
|
-
@
|
147
|
-
@
|
148
|
-
|
149
|
-
@test_by_int_entity = Mod::TestByIntEntity.new(@test_by_int)
|
150
|
-
@test_by_real_entity = Mod::TestByRealEntity.new(@test_by_real)
|
151
|
-
@test_by_auto_counter_entity = Mod::TestByAutoCounterEntity.new(@test_by_auto_counter)
|
152
|
-
@test_by_auto_counter_new_entity = Mod::TestByAutoCounterEntity.new(@test_by_auto_counter_new)
|
153
|
-
@test_by_string_entity = Mod::TestByStringEntity.new(@test_by_string)
|
154
|
-
@test_by_date_entity = Mod::TestByDateEntity.new(@test_by_date)
|
155
|
-
@test_by_date_time_entity = Mod::TestByDateTimeEntity.new(@test_by_date_time)
|
156
|
-
@test_by_decimal_entity = Mod::TestByDecimalEntity.new(@test_by_decimal)
|
157
|
-
@test_by_guid_entity = Mod::TestByGuidEntity.new(@test_by_guid)
|
161
|
+
@test_by_date_time_sub = @constellation.TestByDateTimeSub(@date_time_value)
|
162
|
+
@test_by_decimal_sub = @constellation.TestByDecimalSub('98765432109876543210')
|
163
|
+
@test_by_guid_sub = @constellation.TestByGuidSub('01234567-89ab-cdef-0123-456789abcdef')
|
164
|
+
|
165
|
+
@test_by_int_entity = @constellation.TestByIntEntity(@test_by_int)
|
166
|
+
@test_by_real_entity = @constellation.TestByRealEntity(@test_by_real)
|
167
|
+
@test_by_auto_counter_entity = @constellation.TestByAutoCounterEntity(@test_by_auto_counter)
|
168
|
+
@test_by_auto_counter_new_entity = @constellation.TestByAutoCounterEntity(@test_by_auto_counter_new)
|
169
|
+
@test_by_string_entity = @constellation.TestByStringEntity(@test_by_string)
|
170
|
+
@test_by_date_entity = @constellation.TestByDateEntity(@test_by_date)
|
171
|
+
@test_by_date_time_entity = @constellation.TestByDateTimeEntity(@test_by_date_time)
|
172
|
+
@test_by_decimal_entity = @constellation.TestByDecimalEntity(@test_by_decimal)
|
173
|
+
@test_by_guid_entity = @constellation.TestByGuidEntity(@test_by_guid)
|
174
|
+
@constellation.TestByGuidEntity[[@test_by_guid]].should_not be_nil
|
158
175
|
|
159
176
|
# Entity subtypes
|
160
|
-
@test_sub_by_int =
|
161
|
-
@test_sub_by_real =
|
162
|
-
@test_sub_by_auto_counter =
|
163
|
-
@test_sub_by_auto_counter_new =
|
164
|
-
@test_sub_by_string =
|
165
|
-
@test_sub_by_date =
|
166
|
-
|
167
|
-
@
|
168
|
-
@
|
177
|
+
@test_sub_by_int = @constellation.TestSubByInt(2*2)
|
178
|
+
@test_sub_by_real = @constellation.TestSubByReal(2.0*2)
|
179
|
+
@test_sub_by_auto_counter = @constellation.TestSubByAutoCounter(2*2)
|
180
|
+
@test_sub_by_auto_counter_new = @constellation.TestSubByAutoCounter(:new)
|
181
|
+
@test_sub_by_string = @constellation.TestSubByString("twotwo")
|
182
|
+
@test_sub_by_date = @constellation.TestSubByDate(Date.civil(2008,04*2,28))
|
183
|
+
# Array packing/unpacking obfuscates the following case
|
184
|
+
# @test_sub_by_date_time = @constellation.TestSubByDateTime([2008,04*2,28,10,28,15])
|
185
|
+
@test_sub_by_decimal = @constellation.TestSubByDecimal('987654321098765432109')
|
186
|
+
@test_sub_by_guid = @constellation.TestSubByGuid('01234567-89ab-cdef-0123-456789abcde0')
|
169
187
|
|
170
188
|
# These arrays get zipped together in various ways. Keep them aligned.
|
171
189
|
@values = [
|
@@ -213,7 +231,7 @@ describe "An instance of every type of ObjectType" do
|
|
213
231
|
@test_sub_by_int, @test_sub_by_real, @test_sub_by_auto_counter, @test_sub_by_auto_counter_new,
|
214
232
|
@test_sub_by_string, @test_sub_by_date, @test_sub_by_date_time, @test_sub_by_decimal,
|
215
233
|
@test_sub_by_guid,
|
216
|
-
]
|
234
|
+
].compact
|
217
235
|
@entities_by_entity = [
|
218
236
|
@test_by_int_entity,
|
219
237
|
@test_by_real_entity,
|
@@ -224,7 +242,7 @@ describe "An instance of every type of ObjectType" do
|
|
224
242
|
@test_by_date_time_entity,
|
225
243
|
@test_by_decimal_entity,
|
226
244
|
@test_by_guid_entity,
|
227
|
-
]
|
245
|
+
].compact
|
228
246
|
@entities_by_entity_types = [
|
229
247
|
Mod::TestByIntEntity, Mod::TestByRealEntity, Mod::TestByAutoCounterEntity, Mod::TestByAutoCounterEntity,
|
230
248
|
Mod::TestByStringEntity, Mod::TestByDateEntity, Mod::TestByDateTimeEntity, Mod::TestByDecimalEntity,
|
@@ -243,23 +261,23 @@ describe "An instance of every type of ObjectType" do
|
|
243
261
|
]
|
244
262
|
@role_values = [
|
245
263
|
3, 4.0, 5, 6,
|
246
|
-
"three", Date.
|
264
|
+
"three", Date.civil(2008,4,21), DateTime.civil(2008,4,22,10,28,16),
|
247
265
|
'98765432109876543210',
|
248
266
|
'01234567-89ab-cdef-0123-456789abcdef'
|
249
267
|
]
|
250
268
|
@role_alternate_values = [
|
251
269
|
4, 5.0, 6, 7,
|
252
|
-
"four", Date.
|
270
|
+
"four", Date.civil(2009,4,21), DateTime.civil(2009,4,22,10,28,16),
|
253
271
|
'98765432109876543211',
|
254
272
|
'01234567-89ab-cdef-0123-456789abcdef'
|
255
273
|
]
|
256
274
|
@subtype_role_instances = [
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
275
|
+
@constellation.IntSubVal(6), Mod::RealSubVal.new(6.0),
|
276
|
+
@constellation.AutoCounterSubVal(:new), Mod::AutoCounterSubVal.new(8),
|
277
|
+
@constellation.StringSubVal("seven"),
|
278
|
+
@constellation.DateSubVal(2008,4,29), @constellation.DateTimeSubVal(2008,4,30,10,28,16),
|
279
|
+
@constellation.DecimalSubVal('98765432109876543210'),
|
280
|
+
@constellation.DecimalSubVal('01234567-89ab-cdef-0123-456789abcdef'),
|
263
281
|
]
|
264
282
|
end
|
265
283
|
|
@@ -293,8 +311,13 @@ describe "An instance of every type of ObjectType" do
|
|
293
311
|
end
|
294
312
|
|
295
313
|
it "should inspect" do
|
296
|
-
(@value_instances+@entities+@entities_by_entity).
|
297
|
-
|
314
|
+
(@value_instances+@entities+@entities_by_entity).each_with_index do |object, i|
|
315
|
+
begin
|
316
|
+
object.inspect
|
317
|
+
rescue Exception => e
|
318
|
+
puts "FAILED on #{object.class} at #{i}"
|
319
|
+
raise
|
320
|
+
end
|
298
321
|
end
|
299
322
|
end
|
300
323
|
|
@@ -309,7 +332,6 @@ describe "An instance of every type of ObjectType" do
|
|
309
332
|
|
310
333
|
it "if an entity, should respond to verbalise" do
|
311
334
|
(@entities+@entities_by_entity).each do |entity|
|
312
|
-
#puts entity.verbalise
|
313
335
|
entity.respond_to?(:verbalise).should be_true
|
314
336
|
verbalisation = entity.verbalise
|
315
337
|
verbalisation.should =~ %r{\b#{entity.class.basename}\b}
|
@@ -325,12 +347,14 @@ describe "An instance of every type of ObjectType" do
|
|
325
347
|
|
326
348
|
it "should respond to constellation" do
|
327
349
|
(@value_instances+@entities+@entities_by_entity).each do |instance|
|
350
|
+
next if instance == nil
|
328
351
|
instance.respond_to?(:constellation).should be_true
|
329
352
|
end
|
330
353
|
end
|
331
354
|
|
332
355
|
it "should return the module in response to .vocabulary()" do
|
333
356
|
(@value_types+@entity_types).zip((@value_instances+@entities+@entities_by_entity)).each do |object_type, instance|
|
357
|
+
next if instance == nil
|
334
358
|
instance.class.vocabulary.should == Mod
|
335
359
|
end
|
336
360
|
end
|
@@ -21,10 +21,18 @@ module TestValueTypesModule
|
|
21
21
|
end
|
22
22
|
BASE_VALUE_TYPE_ROLE_NAMES = VALUE_TYPES.map { |base_type| base_type.name.snakecase }
|
23
23
|
VALUE_TYPE_ROLE_NAMES = BASE_VALUE_TYPE_ROLE_NAMES.map { |n| [ :"#{n}_val", :"#{n}_sub_val" ] }.flatten
|
24
|
-
|
24
|
+
|
25
|
+
TestValueTypesModule.module_eval <<-END
|
26
|
+
class Extra < String
|
27
|
+
value_type
|
28
|
+
end
|
29
|
+
END
|
30
|
+
|
31
|
+
VALUE_TYPES.each do |value_type|
|
25
32
|
code = <<-END
|
26
33
|
class #{value_type.name}Val < #{value_type.name}
|
27
34
|
value_type
|
35
|
+
has_one :extra
|
28
36
|
end
|
29
37
|
|
30
38
|
class #{value_type.name}ValSub < #{value_type.name}Val
|
@@ -34,6 +42,7 @@ module TestValueTypesModule
|
|
34
42
|
class #{value_type.name}Entity
|
35
43
|
identified_by :#{identifying_role_name = "id_#{value_type.name.snakecase}_val"}
|
36
44
|
one_to_one :#{identifying_role_name}, :class => #{value_type.name}Val
|
45
|
+
has_one :extra
|
37
46
|
end
|
38
47
|
|
39
48
|
class #{value_type.name}EntitySub < #{value_type.name}Entity
|
@@ -98,6 +107,7 @@ describe "Object type role values" do
|
|
98
107
|
end
|
99
108
|
end
|
100
109
|
|
110
|
+
=begin
|
101
111
|
describe "Instantiating bare objects" do
|
102
112
|
OBJECT_TYPES.each do |object_type|
|
103
113
|
required_value_type = VALUE_TYPE_FOR_OBJECT_TYPE[object_type]
|
@@ -118,6 +128,7 @@ describe "Object type role values" do
|
|
118
128
|
end
|
119
129
|
end
|
120
130
|
end
|
131
|
+
=end
|
121
132
|
|
122
133
|
describe "A constellation" do
|
123
134
|
before :each do
|
@@ -168,20 +179,16 @@ describe "Object type role values" do
|
|
168
179
|
end
|
169
180
|
end
|
170
181
|
|
171
|
-
if object_type.
|
172
|
-
|
173
|
-
# The implementation will need to be reworked to detect problems and reverse any partial changes before chucking an exception
|
174
|
-
=begin
|
175
|
-
it "should not allow re-assigning a #{object_type_name} entity's identifying role value from #{values[0]} to #{values[1]}" do
|
182
|
+
if object_type.is_entity_type
|
183
|
+
it "should allow re-assigning a #{object_type_name} entity's identifying role value from #{values[0]} to #{values[1]}" do
|
176
184
|
object = @constellation.send(object_type_name, *object_identifying_parameters(object_type_name, values[0]))
|
177
185
|
object.class.identifying_roles.each do |identifying_role|
|
178
186
|
next if identifying_role.name == :counter
|
179
187
|
lambda {
|
180
188
|
object.send(:"#{identifying_role.name}=", values[1])
|
181
|
-
}.
|
189
|
+
}.should_not raise_error
|
182
190
|
end
|
183
191
|
end
|
184
|
-
=end
|
185
192
|
|
186
193
|
it "should allow nullifying and reassigning a #{object_type_name} entity's identifying role value" do
|
187
194
|
object = @constellation.send(object_type_name, *object_identifying_parameters(object_type_name, values[0]))
|
@@ -194,21 +201,35 @@ describe "Object type role values" do
|
|
194
201
|
end
|
195
202
|
else
|
196
203
|
it "should allow initialising value type #{object_type.name} with an instance of that value type" do
|
197
|
-
|
204
|
+
params = object_identifying_parameters(object_type_name, values[0])
|
205
|
+
if object_type.respond_to?(:civil)
|
206
|
+
# Handle Date/Time specially:
|
207
|
+
bare_value = object_type.civil(params[0].year)
|
208
|
+
else
|
209
|
+
bare_value = object_type.new(*params)
|
210
|
+
end
|
198
211
|
object = @constellation.send(object_type_name, bare_value)
|
212
|
+
# Here, the bare_value is not the same object which has been added to the constellatiom
|
199
213
|
|
200
214
|
# Now link the bare value to an Octopus:
|
201
215
|
octopus = @constellation.Octopus(0)
|
202
216
|
octopus_role_name = :"octopus_as_one_#{object_type_name.snakecase}"
|
203
|
-
|
204
|
-
counterpart_name =
|
217
|
+
object.send(:"#{octopus_role_name}=", octopus)
|
218
|
+
counterpart_name = object.class.roles[octopus_role_name].counterpart.name
|
205
219
|
|
206
220
|
# Create a reference by assigning the object from a RoleProxy:
|
207
221
|
proxy = octopus.send(counterpart_name)
|
222
|
+
|
208
223
|
#proxy.should be_respond_to(:__getobj__)
|
209
|
-
|
224
|
+
object2 = @constellation.send(object_type_name, proxy)
|
210
225
|
object2.should == object
|
211
226
|
end
|
227
|
+
|
228
|
+
it "should allow adding extra role assignments when asserting an instance" do
|
229
|
+
object = @constellation.send(object_type_name, *(object_identifying_parameters(object_type_name, values[0]) + [{:extra => 'foo'}]))
|
230
|
+
object.extra.should == 'foo'
|
231
|
+
end
|
232
|
+
|
212
233
|
end
|
213
234
|
end
|
214
235
|
|
@@ -161,8 +161,9 @@ describe "Roles" do
|
|
161
161
|
end
|
162
162
|
|
163
163
|
it "should append the counterpart into the respective role array in the matching object_type" do
|
164
|
-
|
165
|
-
|
164
|
+
c = ActiveFacts::API::Constellation.new(Mod)
|
165
|
+
foo = c.Name("Foo")
|
166
|
+
le = c.LegalEntity(foo)
|
166
167
|
le.respond_to?(:name).should be_true
|
167
168
|
name = le.name
|
168
169
|
name.respond_to?(:legal_entity).should be_true
|
@@ -202,38 +203,13 @@ describe "Roles" do
|
|
202
203
|
lambda {p.family.foo}.should raise_error(RuntimeError)
|
203
204
|
end
|
204
205
|
|
205
|
-
it "should keep a trace of the overwritten class when changing identification" do
|
206
|
-
pending
|
207
|
-
c = ActiveFacts::API::Constellation.new(Mod)
|
208
|
-
e = c.Employee(:identifier => "Project2501")
|
209
|
-
e.overrides_identification_of.is_a?(Mod::LegalEntity).should be_true
|
210
|
-
end
|
211
|
-
|
212
206
|
it "should be able to import an entity from another constellation" do
|
213
207
|
c1 = ActiveFacts::API::Constellation.new(Mod)
|
214
208
|
c2 = ActiveFacts::API::Constellation.new(Mod)
|
215
209
|
|
216
210
|
e = c1.Employee("PuppetMaster")
|
217
|
-
identifier = c2.Identifier
|
211
|
+
identifier = c2.Identifier "Project2501", :employee => e
|
218
212
|
identifier.employee.name.should == "PuppetMaster"
|
219
213
|
end
|
220
214
|
|
221
|
-
it "should be able to import an entity from another constellation which subclass another entity" do
|
222
|
-
pending "fails because identify_role_values get only the current class identifying roles" do
|
223
|
-
# in this example, it returns :identifier, but not :name from LegalEntity
|
224
|
-
module Mod
|
225
|
-
class Person2 < LegalEntity
|
226
|
-
identified_by :identifier
|
227
|
-
one_to_one :identifier
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
c1 = ActiveFacts::API::Constellation.new(Mod)
|
232
|
-
c2 = ActiveFacts::API::Constellation.new(Mod)
|
233
|
-
|
234
|
-
p = c1.Person2("Person2Name", :identifier => "Project2501")
|
235
|
-
identifier = c2.Identifier("Project2501", :person2 => p)
|
236
|
-
identifier.person2.name.should == "Person2Name"
|
237
|
-
end
|
238
|
-
end
|
239
215
|
end
|
@@ -51,7 +51,7 @@ describe "identity" do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should be denied" do
|
54
|
-
@change.should raise_error(
|
54
|
+
@change.should raise_error(TypeMigrationException)
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should not change instance subtype" do
|
@@ -61,13 +61,13 @@ describe "identity" do
|
|
61
61
|
it "should have no side-effects" do
|
62
62
|
begin
|
63
63
|
@change.call
|
64
|
-
rescue
|
64
|
+
rescue TypeMigrationException => e
|
65
|
+
# Now check that no unexpected change occurred
|
65
66
|
end
|
66
67
|
|
67
68
|
@p2.should be_nil
|
68
69
|
@c1.Name.values.should =~ [@juliar, @tony]
|
69
70
|
@c1.Name.keys.should =~ [@juliar, @tony]
|
70
|
-
pending "This functionality was poorly implemented and has been temporarily switched off"
|
71
71
|
@c1.TFN.keys.should =~ [123]
|
72
72
|
@c1.Person.values.should =~ [@p1, @p3]
|
73
73
|
@c1.Person.keys.should =~ [[@juliar],[@tony]]
|
@@ -78,7 +78,7 @@ describe "identity" do
|
|
78
78
|
@p2_tfn = @c1.TFN(789)
|
79
79
|
begin
|
80
80
|
@change.call
|
81
|
-
rescue
|
81
|
+
rescue TypeMigrationException => e
|
82
82
|
end
|
83
83
|
|
84
84
|
@c1.TFN.keys.should =~ [123, 789]
|