Index: /ruby/branches/0.5/spec/lib/open_ehr/rm/common/directory/folder_spec.rb
===================================================================
--- /ruby/branches/0.5/spec/lib/open_ehr/rm/common/directory/folder_spec.rb	(revision 338)
+++ /ruby/branches/0.5/spec/lib/open_ehr/rm/common/directory/folder_spec.rb	(revision 338)
@@ -0,0 +1,26 @@
+require File.dirname(__FILE__) + '/../../../../../spec_helper'
+include OpenEHR::RM::Common::Directory
+include OpenEHR::RM::DataTypes::Text
+
+describe Folder do
+  before(:each) do
+    items = stub(Array, :size => 3)
+    folders = stub(Array, :size => 5, :empty? => false)
+    @folder = Folder.new(:archetype_node_id => 'at0001',
+                         :name => DvText.new(:value => 'test'),
+                         :items => items,
+                         :folders => folders)
+  end
+
+  it 'should an instance of Folder' do
+    @folder.should be_an_instance_of Folder
+  end
+
+  it 'items size should be 3' do
+    @folder.items.size.should == 3
+  end
+
+  it 'folders size should be 5' do
+    @folder.folders.size.should == 5
+  end
+end
Index: /ruby/branches/0.5/spec/lib/open_ehr/rm/common/resource/authored_resource_spec.rb
===================================================================
--- /ruby/branches/0.5/spec/lib/open_ehr/rm/common/resource/authored_resource_spec.rb	(revision 338)
+++ /ruby/branches/0.5/spec/lib/open_ehr/rm/common/resource/authored_resource_spec.rb	(revision 338)
@@ -0,0 +1,68 @@
+require File.dirname(__FILE__) + '/../../../../../spec_helper'
+include OpenEHR::RM::Common::Resource
+include OpenEHR::RM::Common::ChangeControl
+include OpenEHR::RM::DataTypes::Text
+
+describe AuthoredResource do
+  before(:each) do
+    original_language = stub(CodePhrase, :code_string => 'ja')
+    translation_language = stub(CodePhrase, :code_string => 'en')
+    translation_details = stub(TranslationDetails,
+                               :language => translation_language)
+    translations = Hash['en', translation_details]
+    description = stub(ResourceDescription, :lifecycle_state => 'initial')
+    revision_history = stub(RevisionHistory, :most_recent_version => '0.0.3')
+    languages_available = Set.new %w(ja en)
+    @authored_resource = AuthoredResource.new(
+                  :original_language => original_language,
+                  :translations => translations,
+                  :description => description,
+                  :revision_history => revision_history)
+  end
+
+  it 'should be an instance of AuthoredResource' do
+    @authored_resource.should be_an_instance_of AuthoredResource
+  end
+
+  it 'original language should be ja' do
+    @authored_resource.original_language.code_string.should == 'ja'
+  end
+
+  it 'translations hash en returns en detail' do
+    @authored_resource.translations['en'].language.code_string.should == 'en'
+  end
+
+  it 'description lifecycle_state should e initial' do
+    @authored_resource.description.lifecycle_state.should == 'initial'
+  end
+
+  it 'language_available should be Set(%(ja en))' do
+    languages_set = Set.new ['ja', 'en']
+    @authored_resource.languages_available.should == languages_set
+  end
+
+  it 'current_revision should be 0.0.3' do
+    @authored_resource.current_revision.should == '0.0.3'
+  end
+
+  it 'should be controlled' do
+    @authored_resource.is_controlled?.should be_true
+  end
+
+  it 'should not be controlled' do
+    @authored_resource.revision_history = nil
+    @authored_resource.is_controlled?.should be_false
+  end
+
+  it 'should raise ArgumentError with empty translations' do
+    lambda {
+      @authored_resource.translations = Array.new
+    }.should raise_error ArgumentError
+  end
+
+  it 'should raise ArgumentError when original language is nil' do
+    lambda {
+      @authored_resource.original_language = nil
+    }.should raise_error ArgumentError
+  end
+end
Index: /ruby/branches/0.5/spec/lib/open_ehr/rm/common/resource/resource_description_item_spec.rb
===================================================================
--- /ruby/branches/0.5/spec/lib/open_ehr/rm/common/resource/resource_description_item_spec.rb	(revision 338)
+++ /ruby/branches/0.5/spec/lib/open_ehr/rm/common/resource/resource_description_item_spec.rb	(revision 338)
@@ -0,0 +1,105 @@
+require File.dirname(__FILE__) + '/../../../../../spec_helper'
+include OpenEHR::RM::Common::Resource
+include OpenEHR::RM::DataTypes::Text
+
+describe ResourceDescriptionItem do
+  before(:each) do
+    language = stub(CodePhrase, :defining_code => 'ja')
+    original_resource_uri = {'jp', 'http://openehr.jp/'}
+    @resource_description_item =
+      ResourceDescriptionItem.new(:language => language,
+                                  :purpose => 'test',
+                                  :keywords => ['openehr'],
+                                  :use => 'development',
+                                  :misuse => 'none',
+                                  :copyright => 'Shinji KOBAYASHI',
+                                  :original_resource_uri => original_resource_uri,
+                                  :other_details => {'charset', 'UTF-8'})
+  end
+
+  it 'should be an instance of ResourceDescriptionItem' do
+    @resource_description_item.should be_an_instance_of ResourceDescriptionItem
+  end
+
+  it 'language should ja' do
+    @resource_description_item.language.defining_code.should == 'ja'
+  end
+
+  it 'purpose should be test' do
+    @resource_description_item.purpose.should == 'test'
+  end
+
+  it 'should raise ArgumentError with nil purpose' do
+    lambda {
+      @resource_description_item.purpose = nil
+    }.should raise_error ArgumentError
+  end
+
+  it 'should raise ArgumentError with empty purpose' do
+    lambda {
+      @resource_description_item.purpose = ''
+    }.should raise_error ArgumentError
+  end
+
+  it 'keywords should [openehr]' do
+    @resource_description_item.keywords.should == ['openehr']
+  end
+
+  it 'use should be development' do
+    @resource_description_item.use.should == 'development'
+  end
+
+  it 'should raise ArgumentError with use is empty' do
+    lambda {
+      @resource_description_item.use = ''
+    }.should raise_error ArgumentError
+  end
+
+  it 'should not raise ArgumentError with nil use' do
+    lambda {
+      @resource_description_item.use = nil
+    }.should_not raise_error ArgumentError
+  end
+
+  it 'misuse should be none' do
+    @resource_description_item.misuse.should == 'none'
+  end
+
+  it 'should raise ArgumentError with empty misuse' do
+    lambda {
+      @resource_description_item.misuse = ''
+    }.should raise_error ArgumentError
+  end
+
+  it 'should not raise ArgumentError with nil misuse' do
+    lambda {
+      @resource_description_item.misuse = nil
+    }.should_not raise_error ArgumentError
+  end
+
+  it 'copyright should be Shinji KOBAYASHI' do
+    @resource_description_item.copyright.should == 'Shinji KOBAYASHI'
+  end
+
+  it 'should raise error with empty copyright' do
+    lambda {
+      @resource_description_item.copyright = ''
+    }.should raise_error ArgumentError
+  end
+
+  it 'should not raise ArgumentError with nil copyright' do
+    lambda {
+      @resource_description_item.copyright = nil
+    }.should_not raise_error ArgumentError
+  end
+
+  it 'original_resource_uri should {jp, http://openehr.jp/}' do
+    @resource_description_item.original_resource_uri.should ==
+      {'jp', 'http://openehr.jp/'}
+  end
+
+  it 'other_details should {charset, UTF-8}' do
+    @resource_description_item.other_details.should ==
+      {'charset', 'UTF-8'}
+  end
+end
Index: /ruby/branches/0.5/spec/lib/open_ehr/rm/common/resource/resource_description_spec.rb
===================================================================
--- /ruby/branches/0.5/spec/lib/open_ehr/rm/common/resource/resource_description_spec.rb	(revision 338)
+++ /ruby/branches/0.5/spec/lib/open_ehr/rm/common/resource/resource_description_spec.rb	(revision 338)
@@ -0,0 +1,74 @@
+require File.dirname(__FILE__) + '/../../../../../spec_helper'
+include OpenEHR::RM::Common::Resource
+
+describe ResourceDescription do
+  before(:each) do
+    original_author = {'Shinji KOBAYASHI', 'Ehime University'}
+    other_contributors = ['Akimichi TATSUKAWA']
+    resource_description_item =
+      stub(ResourceDescriptionItem, :purpose => 'test')
+    details = {'case', resource_description_item}
+    other_details = {'charset', 'UTF-8'}
+    parent_resource = stub(AuthoredResource, :current_revision => '0.0.3')
+    @resource_description =
+      ResourceDescription.new(:original_author => original_author,
+                              :other_contributors => other_contributors,
+                              :lifecycle_state => 'initial',
+                              :details => details,
+                              :other_details => other_details,
+                              :resource_package_uri => 'http://openehr.jp/',
+                              :parent_resource => parent_resource)
+  end
+
+  it 'should be an instance of ResourceDescription' do
+    @resource_description.should be_an_instance_of ResourceDescription
+  end
+
+  it 'original author should be Shinji KOBAYASHI' do
+    @resource_description.original_author.keys[0].should ==
+      'Shinji KOBAYASHI'
+  end
+
+  it 'other_contributors should be Akimichi TATSUKAWA' do
+    @resource_description.other_contributors[0].should == 
+      'Akimichi TATSUKAWA'
+  end
+
+  it 'lifecycle_state should be initial' do
+    @resource_description.lifecycle_state.should == 'initial'
+  end
+
+  it 'details key should be case' do
+    @resource_description.details.keys[0].should == 'case'
+  end
+
+  it 'other_details value should be charset, UTF-8' do
+    @resource_description.other_details.should == {'charset', 'UTF-8'}
+  end
+
+  it 'resource package uri should be http://openehr.jp/' do
+    @resource_description.resource_package_uri.should == 'http://openehr.jp/'
+  end
+
+  it 'parent_resource current_revision should be 0.0.3' do
+    @resource_description.parent_resource.current_revision.should == '0.0.3'
+  end
+
+  it 'should raise ArgumentError with nil original author' do
+    lambda {
+      @resource_description.original_author = nil
+    }.should raise_error ArgumentError
+  end
+
+  it 'should raise ArgumentError with nil lifecycle_state' do
+    lambda {
+      @resource_description.lifecycle_state = nil
+    }.should raise_error ArgumentError
+  end
+
+  it 'should raise ArgumentError with nil details' do
+    lambda {
+      @resource_description.details = {}
+    }.should raise_error ArgumentError
+  end
+end
Index: /ruby/branches/0.5/spec/lib/open_ehr/rm/common/resource/translation_details_spec.rb
===================================================================
--- /ruby/branches/0.5/spec/lib/open_ehr/rm/common/resource/translation_details_spec.rb	(revision 338)
+++ /ruby/branches/0.5/spec/lib/open_ehr/rm/common/resource/translation_details_spec.rb	(revision 338)
@@ -0,0 +1,35 @@
+require File.dirname(__FILE__) + '/../../../../../spec_helper'
+include OpenEHR::RM::Common::Resource
+include OpenEHR::RM::DataTypes::Text
+
+describe TranslationDetails do
+  before(:each) do
+    language = stub(CodePhrase, :code_string => 'ja')
+    author = Hash['Shinji KOBAYASHI', 'Ehime University']
+    @translation_details =
+      TranslationDetails.new(:language => language,
+                             :author => author,
+                             :accreditation => 'skoba@moss.gr.jp',
+                             :other_details => {'ja', 'Japanese'})
+  end
+
+  it 'should be an instance of TranslationDetails' do
+    @translation_details.should be_an_instance_of TranslationDetails
+  end
+
+  it 'language should be ja' do
+    @translation_details.language.code_string.should == 'ja'
+  end
+
+  it 'authour should be Shinji KOBAYASHI' do
+    @translation_details.author.keys[0].should == 'Shinji KOBAYASHI'
+  end
+
+  it 'accreditation should be skoba@moss.gr.jp' do
+    @translation_details.accreditation.should == 'skoba@moss.gr.jp'
+  end
+
+  it 'other_details should ja, Japanese' do
+    @translation_details.other_details.values[0].should == 'Japanese'
+  end
+end
