Index: ruby/trunk/lib/open_ehr/am/archetype/constraint_model.rb
===================================================================
--- ruby/trunk/lib/open_ehr/am/archetype/constraint_model.rb	(revision 373)
+++ ruby/trunk/lib/open_ehr/am/archetype/constraint_model.rb	(revision 374)
@@ -1,3 +1,2 @@
-
 module OpenEHR
   module AM
Index: ruby/trunk/spec/lib/open_ehr/am/archetype/archetype_spec.rb
===================================================================
--- ruby/trunk/spec/lib/open_ehr/am/archetype/archetype_spec.rb	(revision 374)
+++ ruby/trunk/spec/lib/open_ehr/am/archetype/archetype_spec.rb	(revision 374)
@@ -0,0 +1,98 @@
+require File.dirname(__FILE__) + '/../../../../spec_helper'
+include OpenEHR::AM::Archetype
+include OpenEHR::AM::Archetype::ConstraintModel
+include OpenEHR::AM::Archetype::Ontology
+include OpenEHR::RM::DataTypes::Text
+include OpenEHR::RM::Common::Resource
+include OpenEHR::RM::Support::Identification
+
+describe Archetype do
+  before(:each) do
+    original_language = stub(CodePhrase, :code_string => 'ja')
+    archetype_id = ArchetypeID.new(:value => 'openEHR-EHR-SECTION.physical_examination-prenatal.v2')
+    definition = stub(CComplexObject, :rm_type_name => 'SECTION')
+    ontology = stub(ArchetypeOntology, :specialisation_depth => 1)
+    uid = HierObjectID.new(:value => 'ABCD::1')
+    parent_archetype_id = ArchetypeID.new(:value => 'openEHR-EHR-SECTION.physical_examination.v1')
+    invariants = stub(Set, :size => 2)
+    @archetype = Archetype.new(:original_language => original_language,
+                               :adl_version => '1.4',
+                               :archetype_id => archetype_id,
+                               :concept => 'at0000',
+                               :definition => definition,
+                               :ontology => ontology,
+                               :uid => uid,
+                               :parent_archetype_id => parent_archetype_id,
+                               :invariants => invariants)
+  end
+
+  it 'should be an instance of Archetype' do
+    @archetype.should be_an_instance_of Archetype
+  end
+
+  it 'adl_version should be assigned properly' do
+    @archetype.adl_version.should == '1.4'
+  end
+  
+  it 'archetype_id should be assigned prorperly' do
+    @archetype.archetype_id.value.should == 'openEHR-EHR-SECTION.physical_examination-prenatal.v2'
+  end
+
+  it 'should raise ArgumentError when archetype_id is nil' do
+    lambda {
+      @archetype.archetype_id = nil
+    }.should raise_error ArgumentError
+  end
+
+  it 'uid should be assigned properly' do
+    @archetype.uid.value.should == 'ABCD::1'
+  end
+
+  it 'concept should be assigned properly' do
+    @archetype.concept.should == 'at0000'
+  end
+
+  it 'should raise ArgumentError when concept is nil' do
+    lambda {
+      @archetype.concept = nil
+    }.should raise_error ArgumentError
+  end
+
+  it 'parent_archetype_id should be assigned properly' do
+    @archetype.parent_archetype_id.value.should == 'openEHR-EHR-SECTION.physical_examination.v1'
+  end
+
+  it 'definition should be assigned properly' do
+    @archetype.definition.rm_type_name.should == 'SECTION'
+  end
+
+  it 'should raise ArgumentError when definition is nil' do
+    lambda {
+      @archetype.definition = nil
+    }.should raise_error ArgumentError
+  end
+  
+  it 'ontology should be assigned properly' do
+    @archetype.ontology.specialisation_depth.should be_equal 1
+  end
+
+  it 'should raise ArgumentError when ontology is nil' do
+    lambda {
+      @archetype.ontology = nil
+    }.should raise_error ArgumentError
+  end
+
+  it 'invariants should be assigned properly' do
+    @archetype.invariants.size.should be_equal 2
+  end
+
+  it 'version should be extracted form id' do
+    @archetype.version.should == 'v2'
+  end
+
+  it 'short concept name should be extracted from archetype id' do
+    @archetype.short_concept_name.should == 'physical_examination'
+  end
+
+  it 'concept name should be extracted from ontology'
+end
Index: ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/archetype_constraint_spec.rb
===================================================================
--- ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/archetype_constraint_spec.rb	(revision 374)
+++ ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/archetype_constraint_spec.rb	(revision 374)
@@ -0,0 +1,56 @@
+require File.dirname(__FILE__) + '/../../../../../spec_helper'
+include OpenEHR::AM::Archetype::ConstraintModel
+
+describe ArchetypeConstraint do
+  before(:each) do
+    parent = stub(ArchetypeConstraint, :path => '/data/[at0001]')
+    @archetype_constraint =
+      ArchetypeConstraint.new(:path => '/data/events[at0003]/data/items[at0025]/value/magnitude',
+                              :parent => parent)
+  end
+
+  it 'should be an instance of ArchetypeConstraint' do
+    @archetype_constraint.should be_an_instance_of ArchetypeConstraint
+  end
+
+  it 'path should be assigned properly' do
+    @archetype_constraint.path.should == '/data/events[at0003]/data/items[at0025]/value/magnitude'
+  end
+
+  it 'should raise ArgumentError when path is not assigned' do
+    lambda {
+      @archetype_constraint.path = nil
+    }.should raise_error ArgumentError
+  end
+
+  it 'has_path? should return true if it has path' do
+    @archetype_constraint.should have_path 'events[at0003]'
+  end
+
+  it 'has_path? should return false if ti does not have path' do
+    @archetype_constraint.should_not have_path 'events[at0004]'
+  end
+
+  it 'parent should assigned properly' do
+    @archetype_constraint.parent.path.should == '/data/[at0001]'
+  end
+
+  it 'is congruent means this node starts from parent node' do
+    @archetype_constraint.should_not be_congruent
+  end
+
+  it 'is congruent when path starts with parent path' do
+    @archetype_constraint.path = '/data/[at0001]/test'
+    @archetype_constraint.should be_congruent
+  end
+
+  it 'node_conforms_to return true if path is follower' do
+    other = stub(ArchetypeConstraint, :path => '/data/events[at0003]')
+    @archetype_constraint.node_conforms_to?(other).should be_true
+  end
+
+  it 'node_conforms_to return false if path is other lineage' do
+    other = stub(ArchetypeConstraint, :path => '/event/')
+    @archetype_constraint.node_conforms_to?(other).should be_false
+  end
+end
Index: ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/c_primitive_object_spec.rb
===================================================================
--- ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/c_primitive_object_spec.rb	(revision 374)
+++ ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/c_primitive_object_spec.rb	(revision 374)
@@ -0,0 +1,11 @@
+require File.dirname(__FILE__) + '/../../../../../spec_helper'
+
+describe CPrimitiveObject do
+  before(:each) do
+    @c_primitive_object = CPrimitiveObject.new
+  end
+
+  it 'should be an instance of CPrimitiveObject' do
+    @c_primitive_object.should be_an_instance_of CPrimitiveObject
+  end
+end
