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.
@@ -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 :each do
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 = Mod::IntVal.new(1)
100
- @real_value = Mod::RealVal.new(1.0)
101
- @auto_counter_value = Mod::AutoCounterVal.new(1)
102
- @new_auto_counter_value = Mod::AutoCounterVal.new(:new)
103
- @string_value = Mod::StringVal.new("one")
104
- @date_value = Mod::DateVal.new(2008, 04, 20)
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 = Mod::DateVal.new '2nd Nov 2001'
114
+ @date_value = @constellation.DateVal('2nd Nov 2001')
107
115
  d = ::Date.civil(2008, 04, 20)
108
- @date_time_value = Mod::DateTimeVal.new d # 2008, 04, 20, 10, 28, 14
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 = Mod::DecimalVal.new(BigDecimal.new('98765432109876543210'))
111
- @guid_value = Mod::GuidVal.new(:new)
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 = Mod::IntSubVal.new(4)
115
- @real_sub_value = Mod::RealSubVal.new(4.0)
116
- @auto_counter_sub_value = Mod::AutoCounterSubVal.new(4)
117
- @auto_counter_sub_value_new = Mod::AutoCounterSubVal.new(:new)
118
- @string_sub_value = Mod::StringSubVal.new("five")
119
- @date_sub_value = Mod::DateSubVal.new(2008, 04, 25)
120
- @date_time_sub_value = Mod::DateTimeSubVal.new(::DateTime.civil(2008, 04, 26, 10, 28, 14))
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 = Mod::DecimalSubVal.new(98765432109876543210)
123
- @guid_sub_value = Mod::GuidSubVal.new(:new)
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 = Mod::TestByInt.new(2)
127
- @test_by_real = Mod::TestByReal.new(2.0)
128
- @test_by_auto_counter = Mod::TestByAutoCounter.new(2)
129
- @test_by_auto_counter_new = Mod::TestByAutoCounter.new(:new)
130
- @test_by_string = Mod::TestByString.new("two")
131
- @test_by_date = Mod::TestByDate.new(Date.new(2008,04,28))
132
- #@test_by_date = Mod::TestByDate.new(2008,04,28)
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
- @test_by_date_time = Mod::TestByDateTime.new([[2008,04,28,10,28,15]])
135
- #@test_by_date_time = Mod::TestByDateTime.new(DateTime.new(2008,04,28,10,28,15))
136
- @test_by_decimal = Mod::TestByDecimal.new('98765432109876543210')
137
- @test_by_guid = Mod::TestByGuid.new('01234567-89ab-cdef-0123-456789abcdef')
138
-
139
- @test_by_int_sub = Mod::TestByIntSub.new(2)
140
- @test_by_real_sub = Mod::TestByRealSub.new(5.0)
141
- @test_by_auto_counter_sub = Mod::TestByAutoCounterSub.new(6)
142
- @test_by_auto_counter_new_sub = Mod::TestByAutoCounterSub.new(:new)
143
- @test_by_string_sub = Mod::TestByStringSub.new("six")
144
- @test_by_date_sub = Mod::TestByDateSub.new(Date.new(2008,04,27))
145
- @test_by_date_time_sub = Mod::TestByDateTimeSub.new(2008,04,29,10,28,15)
146
- @test_by_decimal_sub = Mod::TestByDecimalSub.new('98765432109876543210')
147
- @test_by_guid_sub = Mod::TestByGuidSub.new('01234567-89ab-cdef-0123-456789abcdef')
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 = Mod::TestSubByInt.new(2)
161
- @test_sub_by_real = Mod::TestSubByReal.new(2.0)
162
- @test_sub_by_auto_counter = Mod::TestSubByAutoCounter.new(2)
163
- @test_sub_by_auto_counter_new = Mod::TestSubByAutoCounter.new(:new)
164
- @test_sub_by_string = Mod::TestSubByString.new("two")
165
- @test_sub_by_date = Mod::TestSubByDate.new(Date.new(2008,04,28))
166
- @test_sub_by_date_time = Mod::TestSubByDateTime.new(2008,04,28,10,28,15)
167
- @test_sub_by_decimal = Mod::TestSubByDecimal.new('98765432109876543210')
168
- @test_sub_by_guid = Mod::TestSubByGuid.new('01234567-89ab-cdef-0123-456789abcdef')
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.new(2008,4,21), DateTime.new(2008,4,22,10,28,16),
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.new(2009,4,21), DateTime.new(2009,4,22,10,28,16),
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
- Mod::IntSubVal.new(6), Mod::RealSubVal.new(6.0),
258
- Mod::AutoCounterSubVal.new(:new), Mod::AutoCounterSubVal.new(8),
259
- Mod::StringSubVal.new("seven"),
260
- Mod::DateSubVal.new(2008,4,29), Mod::DateTimeSubVal.new(2008,4,30,10,28,16),
261
- Mod::DecimalSubVal.new('98765432109876543210'),
262
- Mod::DecimalSubVal.new('01234567-89ab-cdef-0123-456789abcdef'),
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).each do |object|
297
- object.inspect
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
- VALUE_TYPES.map do |value_type|
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.respond_to?(:identifying_roles)
172
- # REVISIT: Here, there are many possible problems with re-assigning identifying role values. We need tests!
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
- }.should raise_error
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
- bare_value = object_type.new(*object_identifying_parameters(object_type_name, values[0]))
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
- bare_value.send(:"#{octopus_role_name}=", octopus)
204
- counterpart_name = bare_value.class.roles[octopus_role_name].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
- object2 = @constellation.send(object_type_name, proxy)
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
- foo = Mod::Name.new("Foo")
165
- le = Mod::LegalEntity.new(foo)
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("Project2501", :employee => e)
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
@@ -42,6 +42,7 @@ describe "An Entity Type" do
42
42
 
43
43
  describe "when asserted" do
44
44
  before :each do
45
+ @bus = @c.Business
45
46
  @bus = @c.Business('Acme')
46
47
  @acme = @c.Name['Acme']
47
48
  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(DuplicateIdentifyingValueException)
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 DuplicateIdentifyingValueException => e
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 DuplicateIdentifyingValueException => e
81
+ rescue TypeMigrationException => e
82
82
  end
83
83
 
84
84
  @c1.TFN.keys.should =~ [123, 789]