Index: ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/c_attribute_spec.rb
===================================================================
--- ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/c_attribute_spec.rb	(revision 375)
+++ ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/c_attribute_spec.rb	(revision 375)
@@ -0,0 +1,59 @@
+require File.dirname(__FILE__) + '/../../../../../spec_helper'
+include OpenEHR::AM::Archetype::ConstraintModel
+include OpenEHR::AssumedLibraryTypes
+
+describe CAttribute do
+  before(:each) do
+    existence = Interval.new(:lower => 0, :upper => 1)
+    children = stub(CObject, :rm_type_name => 'DV_AMOUNT')
+    @c_attribute = CAttribute.new(:path => '/event/[at0001]/',
+                                  :rm_attribute_name => 'DV_TEXT',
+                                  :existence => existence,
+                                  :children => children)
+  end
+
+  it 'should be an instance of CAttribute' do
+    @c_attribute.should be_an_instance_of CAttribute
+  end
+
+  it 'rm_attribute_name should be assigned properly' do
+    @c_attribute.rm_attribute_name.should == 'DV_TEXT'
+  end
+
+  it 'should raise ArguemntError rm_attribute_name is empty' do
+    lambda {
+      @c_attribute.rm_attribute_name = ''
+    }.should raise_error ArgumentError
+  end
+
+  it 'should raise ArgumentError rm_attribute_name is nil' do
+    lambda {
+      @c_attribute.rm_attribute_name = nil
+    }.should raise_error ArgumentError
+  end
+
+  it 'existence should be assigned properly' do
+    @c_attribute.existence.lower.should be_equal 0
+  end
+
+  it 'existence.lower should be more than 0' do
+    invalid_existence = Interval.new(:lower => -1, :upper => 1)
+    lambda {
+      @c_attribute.existence = invalid_existence
+    }.should raise_error ArgumentError
+  end
+
+  it 'existence.upper should be equal or less than 1' do
+    invalid_existence = Interval.new(:lower => 0, :upper => 2)
+    lambda {
+      @c_attribute.existence = invalid_existence
+    }.should raise_error ArgumentError
+  end
+
+  it 'children should be assigned properly' do
+    @c_attribute.children.rm_type_name.should == 'DV_AMOUNT'
+  end
+end
+
+
+
Index: ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/c_object_spec.rb
===================================================================
--- ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/c_object_spec.rb	(revision 375)
+++ ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/c_object_spec.rb	(revision 375)
@@ -0,0 +1,61 @@
+require File.dirname(__FILE__) + '/../../../../../spec_helper'
+include OpenEHR::AM::Archetype::ConstraintModel
+include OpenEHR::AssumedLibraryTypes
+
+describe CObject do
+  before(:each) do
+    occurrences = Interval.new(:lower => 0, :upper => 1)
+    parent = stub(CAttribute, :rm_attribute_name => 'DV_DATE')
+    @c_object = CObject.new(:path => '/event/[at0001]/',
+                            :rm_type_name => 'DV_TIME',
+                            :node_id => 'ac0001',
+                            :occurrences => occurrences,
+                            :parent => parent)
+  end
+
+  it 'should be an instance of CObject' do
+    @c_object.should be_an_instance_of CObject
+  end
+
+  it 'rm_type_name should be assigned properly' do
+    @c_object.rm_type_name.should == 'DV_TIME'
+  end
+
+  it 'should raise ArgumentError when rm_type_name was assigned nil' do
+    lambda {
+      @c_object.rm_type_name = nil
+    }.should raise_error ArgumentError
+  end
+
+  it 'should raise ArgumentError when rm_type_name was assigned empty' do
+    lambda {
+      @c_object.rm_type_name = ''
+    }.should raise_error ArgumentError
+  end
+
+  it 'node_id should be assigned properly' do
+    @c_object.node_id.should == 'ac0001'
+  end
+
+  it 'should raise ArgumentError when node_id was assigned nil' do
+    lambda {
+      @c_object.node_id = nil
+    }.should raise_error ArgumentError
+  end
+
+  it 'should raise ArgumentError when node_id was assigned empty' do
+    lambda {
+      @c_object.node_id = ''
+    }.should raise_error ArgumentError
+  end
+
+  it 'occurences should be assigned properly' do
+    @c_object.occurrences.lower.should be_equal 0
+  end
+
+  it 'should raise ArgumentError when occurences was assigned nil' do
+    lambda {
+      @c_object.occurrences = nil
+    }.should raise_error ArgumentError
+  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 375)
@@ -1,7 +1,13 @@
 require File.dirname(__FILE__) + '/../../../../../spec_helper'
+include OpenEHR::AM::Archetype::ConstraintModel
+include OpenEHR::AssumedLibraryTypes
 
 describe CPrimitiveObject do
   before(:each) do
-    @c_primitive_object = CPrimitiveObject.new
+    interval = Interval.new(:lower => 0, :upper => 1)
+    @c_primitive_object = CPrimitiveObject.new(:path => 'event/test',
+                                               :rm_type_name => 'DV_TEXT',
+                                               :node_id => 'ac0001',
+                                               :occurrences => interval)
   end
 
Index: ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/cardinality_spec.rb
===================================================================
--- ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/cardinality_spec.rb	(revision 375)
+++ ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/cardinality_spec.rb	(revision 375)
@@ -0,0 +1,68 @@
+require File.dirname(__FILE__) + '/../../../../../spec_helper'
+include OpenEHR::AM::Archetype::ConstraintModel
+include OpenEHR::AssumedLibraryTypes
+
+describe Cardinality do
+  before(:each) do
+    interval = Interval.new(:upper => 1, :lower => 0)
+    @cardinality = Cardinality.new(:is_ordered => true,
+                                   :is_unique => true,
+                                   :interval => interval)
+  end
+
+  it 'should be an instance of Cardinality' do
+    @cardinality.should be_an_instance_of Cardinality
+  end
+
+  it 'is_ordered should be assigned properly' do
+    @cardinality.should be_ordered
+  end
+
+  it 'is_ordered should be false' do
+    @cardinality.is_ordered = false
+    @cardinality.should_not be_ordered
+  end
+
+  it 'is_unique should be assigned properly' do
+    @cardinality.should be_unique
+  end
+
+  it 'is_unique should not be true' do
+    @cardinality.is_unique = false
+    @cardinality.should_not be_unique
+  end
+
+  it 'interval should be assigned properly' do
+    @cardinality.interval.upper.should be_equal 1
+  end
+
+  it 'is_set represent not ordered and unique' do
+    @cardinality.should_not be_set
+  end
+
+  it 'is_set should be true' do
+    @cardinality.is_unique = true
+    @cardinality.is_ordered = false
+    @cardinality.should be_set
+  end
+
+  it 'is_list represent ordered and not unique' do
+    @cardinality.is_ordered = true
+    @cardinality.is_unique = false
+    @cardinality.should be_list
+  end
+
+  it 'is_list should not be true' do
+    @cardinality.should_not be_list
+  end
+
+  it 'is_bag represent not ordered and not unique' do
+    @cardinality.is_ordered = false
+    @cardinality.is_unique = false
+    @cardinality.should be_bag
+  end
+
+  it 'is_bag? should not be true' do
+    @cardinality.should_not be_bag
+  end
+end
