spec/identification_scheme/identification_spec.rb in activefacts-api-0.9.9 vs spec/identification_scheme/identification_spec.rb in activefacts-api-1.0.0
- old
+ new
@@ -3,37 +3,37 @@
# Copyright (c) 2008 Clifford Heath. Read the LICENSE file.
#
describe "An Entity Type" do
before :all do
- module Mod
+ module ModIS
class Name < String
value_type
end
class Number < Int
value_type
end
end
end
before :each do
- @c = ActiveFacts::API::Constellation.new(Mod)
+ @c = ActiveFacts::API::Constellation.new(ModIS)
end
describe "whose instances are identified by a single value role" do
before :all do
- module Mod
+ module ModIS
class Business
identified_by :name
one_to_one :name
end
end
end
it "should fail if the role isn't one-to-one" do
proc do
- module Mod
+ module ModIS
class Cat
identified_by :name
has_one :name
end
end
@@ -46,15 +46,15 @@
@bus = @c.Business('Acme')
@acme = @c.Name['Acme']
end
it "should return a new instance if not previously present" do
- @bus.should be_a(Mod::Business)
+ @bus.should be_a(ModIS::Business)
end
it "should assert the identifying value" do
- @acme.should be_a(Mod::Name)
+ @acme.should be_a(ModIS::Name)
end
it "should be found in the constellation using the value" do
@c.Business[['Acme']].should == @bus
@c.Business[[@acme]].should == @bus
@@ -95,11 +95,11 @@
before :each do
@bus.name = 'Bloggs'
end
it "should assert the new identifier" do
- @c.Name['Bloggs'].should be_a(Mod::Name)
+ @c.Name['Bloggs'].should be_a(ModIS::Name)
end
it "should allow the change" do
@bus.name.should == 'Bloggs'
@c.Business.size.should == 2
@@ -166,11 +166,11 @@
end
end
describe "and the identifying value plays other roles" do
before :all do
- module Mod
+ module ModIS
class Dog
identified_by :name
one_to_one :name
end
end
@@ -189,11 +189,11 @@
end
end
describe "identified by two values" do
before :all do
- module Mod
+ module ModIS
class Building
identified_by :name
one_to_one :name
end
@@ -220,16 +220,16 @@
end
end
end
before :each do
- @c = ActiveFacts::API::Constellation.new(Mod)
+ @c = ActiveFacts::API::Constellation.new(ModIS)
end
it "should fail if any role is one-to-one" do
proc do
- module Mod
+ module ModIS
class Floor
identified_by :building, :number
has_one :building
one_to_one :number # Error, invalid identifier
end
@@ -247,15 +247,15 @@
@o = @c.Owner(1_001, @b)
@or = @c.OwnerRoom(@o, @r)
end
it "should return a new instance if not previously present" do
- @r.should be_a(Mod::Room)
+ @r.should be_a(ModIS::Room)
end
it "should assert the identifying values" do
- @rn.should be_a(Mod::Number)
+ @rn.should be_a(ModIS::Number)
@c.Number[@rn.identifying_role_values].should == @rn # Yes
@c.Number[101].should == @rn # No
@c.Number[101].should be_eql 101 # No
end
@@ -316,10 +316,13 @@
@c.Room[[@b.identifying_role_values, 103]].should == @r
@c.Room[[['Mackay'], 101]].should be_nil
end
it "should be found under the new identifier even on deep associations" do
+# p @c.OwnerRoom.keys[0]
+# p @new_number
+# p [@o.identifying_role_values, @r.identifying_role_values]
@c.OwnerRoom[[@o.identifying_role_values, @r.identifying_role_values]].should == @or
@c.OwnerRoom[[[1_001, ['Mackay']], [['Mackay'], 103]]].should == @or
@c.OwnerRoom[[[1_001, ['Mackay']], [['Mackay'], 101]]].should be_nil
end
@@ -376,10 +379,10 @@
end
end
describe "which has a supertype that has separate identification" do
before :each do
- module Mod
+ module ModIS
class Animal
identified_by :number
one_to_one :neumber
end
class Dog < Animal