Permalink
Browse files

Add tests for coverage.

  • Loading branch information...
1 parent 63f4e43 commit 7150045f7a802fff90f73dc6dd21648610472bd8 @kouno committed Aug 16, 2012
View
12 lib/activefacts/api/entity.rb
@@ -163,12 +163,14 @@ def identifying_roles
end
def find_inherited_role(role_name)
- if !superclass.is_entity_type
- false
- elsif superclass.roles.has_key?(role_name)
- superclass.roles[role_name]
+ if superclass.is_entity_type
+ if superclass.roles.has_key?(role_name)
+ superclass.roles[role_name]
+ else
+ superclass.find_inherited_role(role_name)
+ end
else
- superclass.find_inherited_role(role_name)
+ false
end
end
View
8 lib/activefacts/api/numeric.rb
@@ -177,14 +177,6 @@ def inspect
"\#<AutoCounter "+to_s+">"
end
- def hash #:nodoc:
- if self.defined?
- @value.hash
- else
- 0
- end
- end
-
def <=>(other)
to_s <=> other.to_s
end
View
4 lib/activefacts/api/role.rb
@@ -55,10 +55,6 @@ def unary?
counterpart == nil
end
- def is_inherited?(klass)
- klass.supertypes_transitive.include?(@object_type)
- end
-
def counterpart_object_type
# This method is sometimes used when unaries are used in an entity's identifier.
@is_unary ? TrueClass : (counterpart ? counterpart.object_type : nil)
View
6 spec/fact_type/roles_spec.rb
@@ -41,6 +41,12 @@ class Employee
# print "object_type: "; p Mod.object_type
end
+ it "should find inherited roles" do
+ Mod::Person.find_inherited_role(:name).should be_an_instance_of Role # name is defined on LegalEntity
+ Mod::Person.find_inherited_role(:family).should be_false # family is defined on Person
+ Mod::Person.find_inherited_role(:non_existing_role).should be_false
+ end
+
it "should associate a role name with a matching existing object_type" do
module Mod
class Existing1 < String
View
15 spec/identification_scheme/identification_spec.rb
@@ -71,6 +71,21 @@ class Cat
@c.Business[['Acme']].should == @bus
@c.Business.size.should == 1
end
+
+ describe "when compared to a subtype" do
+ before :each do
+ module Mod
+ class SubBusiness < Business
+ end
+ end
+ @sub_business = @c.Business('Bcme')
+ end
+
+ it "should not be eql?" do
+ @business.eql?(@sub_business).should be_false
+ @sub_business.eql?(@business).should be_false
+ end
+ end
end
describe "when the value is changed" do

0 comments on commit 7150045

Please sign in to comment.