Index: ruby/trunk/lib/open_ehr/am/archetype/ontology.rb
===================================================================
--- ruby/trunk/lib/open_ehr/am/archetype/ontology.rb	(revision 402)
+++ ruby/trunk/lib/open_ehr/am/archetype/ontology.rb	(revision 403)
@@ -6,5 +6,20 @@
           attr_accessor :constraint_codes, :specialisation_depth
           attr_accessor :term_attribute_names, :term_codes
-          attr_accessor :terminologies_available
+          attr_reader :terminologies_available
+
+          def initialize(args = { })
+            self.terminologies_available = args[:terminologies_available]
+            self.specialisation_depth = args[:specialisation_depth]
+            self.term_codes = args[:term_codes]
+            self.constraint_codes = args[:constraint_codes]
+            self.term_attribute_names = args[:term_attribute_names]
+          end
+
+          def terminologies_available=(terminologies_available)
+            if terminologies_available.nil?
+              raise ArgumentError, 'terminologies_available is mandatory'
+            end
+            @terminologies_available = terminologies_available
+          end
 
           def constraint_binding(a_terminology, a_code)
Index: ruby/trunk/spec/lib/open_ehr/am/archetype/ontology/archetype_ontology_spec.rb
===================================================================
--- ruby/trunk/spec/lib/open_ehr/am/archetype/ontology/archetype_ontology_spec.rb	(revision 403)
+++ ruby/trunk/spec/lib/open_ehr/am/archetype/ontology/archetype_ontology_spec.rb	(revision 403)
@@ -0,0 +1,48 @@
+require File.dirname(__FILE__) + '/../../../../../spec_helper'
+include OpenEHR::AM::Archetype::Ontology
+
+describe ArchetypeOntology do
+  before(:each) do
+    terminologies_available = stub(Set, :size =>1)
+    term_codes = stub(Array, :size => 2)
+    constraint_codes = stub(Array, :size => 3)
+    term_attribute_names = stub(Array, :size => 4)
+    @archetype_ontology =
+      ArchetypeOntology.new(:terminologies_available => terminologies_available,
+                            :specialisation_depth => 0,
+                            :term_codes => term_codes,
+                            :constraint_codes => constraint_codes,
+                            :term_attribute_names => term_attribute_names)
+  end
+
+  it 'should be an instance of ArchetypeOntology' do
+    @archetype_ontology.should be_an_instance_of ArchetypeOntology
+  end
+
+  it 'terminologies_available should be assigned properly' do
+    @archetype_ontology.terminologies_available.size.should be_equal 1
+  end
+
+  it 'should raise ArgumentError if terminologies_available is nil' do
+    lambda {
+      @archetype_ontology.terminologies_available = nil
+    }.should raise_error ArgumentError
+  end
+
+  it 'term_codes should be assigned properly' do
+    @archetype_ontology.term_codes.size.should be_equal 2
+  end
+
+  it 'specialisation depth should be assigned properly' do
+    @archetype_ontology.specialisation_depth.should be_equal 0
+  end
+
+  it 'constraint_codes should be assigned properly' do
+    @archetype_ontology.constraint_codes.size.should be_equal 3
+  end
+
+  it 'term_attribute_names should be assigned properly' do
+    @archetype_ontology.term_attribute_names.size.should be_equal 4
+  end
+end
+                            
Index: ruby/trunk/spec/lib/open_ehr/am/archetype/ontology/archetype_term_spec.rb
===================================================================
--- ruby/trunk/spec/lib/open_ehr/am/archetype/ontology/archetype_term_spec.rb	(revision 403)
+++ ruby/trunk/spec/lib/open_ehr/am/archetype/ontology/archetype_term_spec.rb	(revision 403)
@@ -0,0 +1,43 @@
+require File.dirname(__FILE__) + '/../../../../../spec_helper'
+include OpenEHR::AM::Archetype::Ontology
+
+describe ArchetypeTerm do
+  before(:each) do
+    items = Hash['TEXT', 'text']
+    @archetype_term = ArchetypeTerm.new(:code => 'at0001',
+                                        :items => items)
+  end
+
+  it 'should be an instance of ArchetypeTerm' do
+    @archetype_term.should be_an_instance_of ArchetypeTerm
+  end
+
+  it 'code should be assigned properly' do
+    @archetype_term.code.should == 'at0001'
+  end
+
+  it 'should raise ArgumentError if code is nil' do
+    lambda {
+      @archetype_term.code = nil
+    }.should raise_error ArgumentError
+  end
+
+  it 'should raise ArgumentError if code is empty' do
+    lambda {
+      @archetype_term.code = ''
+    }.should raise_error ArgumentError
+  end
+
+  it 'items should be assigned properly' do
+    @archetype_term.items['TEXT'].should == 'text'
+  end
+
+  it 'keys should be a set of keys of item' do
+    @archetype_term.keys.should == Set.new('TEXT')
+  end
+
+  it 'keys should be empty if items are nil' do
+    @archetype_term.items = nil
+    @archetype_term.keys.should == Set.new
+  end
+end
