Changeset 301 for ruby/branches


Ignore:
Timestamp:
Sep 26, 2009, 10:15:57 PM (15 years ago)
Author:
KOBAYASHI, Shinji
Message:

locatable class completed

Location:
ruby/branches/0.5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ruby/branches/0.5/lib/open_ehr/rm/common/archetyped.rb

    r300 r301  
    7878          end
    7979
    80           def item_at_path(path)
    81             if !@path.nil?
    82               if @path == ""
    83                 raise ArgumentError, "path is not valid"
    84               end
     80          def concept
     81            if self.is_archetype_root?
     82              return DvText.new(:value =>
     83                                @archetype_details.archetype_id.concept_name)
     84            else
     85              raise ArgumentError, 'this is not root'
    8586            end
    86           end
    87 
    88           def concept
    89             return DvText.new(:value =>
    90                               @archetype_details.archetype_id.concept_name)
    9187          end
    9288
  • ruby/branches/0.5/spec/lib/open_ehr/rm/common/archetyped/locatable_spec.rb

    r300 r301  
    99    link = stub(Set, :size => 10, :empty? => false)
    1010    uid = UIDBasedID.new(:value => 'ehr::localhost/3030')
    11     archetype_details = stub(Archetyped, :rm_version =>  '1.2.4')
     11    archetype_id = ArchetypeID.new(:value =>
     12                           'openEHR-EHR-SECTION.physical_examination.v2')
     13    archetype_details = stub(Archetyped, :rm_version =>  '1.2.4',
     14                             :archetype_id => archetype_id)
     15    feeder_audit = stub(FeederAudit, :system_id => 'MAGI')
    1216    @locatable = Locatable.new(:archetype_node_id => 'at001',
    1317                               :name => name,
    1418                               :links => link,
    1519                               :uid => uid,
     20                               :feeder_audit => feeder_audit,
    1621                               :archetype_details => archetype_details)
    1722  end
     
    2328  it 'archetype_node_id should be at001' do
    2429    @locatable.archetype_node_id.should == 'at001'
     30  end
     31
     32  it 'is_archetype_root? should be true' do
     33    @locatable.is_archetype_root?.should be_true
     34  end
     35
     36  it 'is_archetype_root? should be false when archetype_details is nil' do
     37    @locatable.archetype_details = nil
     38    @locatable.is_archetype_root?.should be_false
    2539  end
    2640
     
    4155  end
    4256
     57  it 'feeer_audit.system_id should MAGI' do
     58    @locatable.feeder_audit.system_id.should == 'MAGI'
     59  end
     60
     61  it 'concept should be physical_examination' do
     62    @locatable.concept.value.should == 'physical_examination'
     63  end
     64
    4365  it 'should raise ArgumentError with nil archetype_node_id' do
    4466    lambda {
     
    4769  end
    4870
     71  it 'should raise ArgumentError with nil name' do
     72    lambda {
     73      @locatable.name = nil
     74    }.should raise_error ArgumentError
     75  end
     76
     77  it 'should raise ArgumentError with empty links' do
     78    lambda {
     79      @locatable.links = Set.new
     80    }.should raise_error ArgumentError
     81  end
     82
     83  it 'should raise ArgumentError Archetyped invalid' do
     84    @locatable.archetype_details = nil
     85    lambda {
     86      @locatable.concept
     87    }.should raise_error ArgumentError
     88  end
    4989end
Note: See TracChangeset for help on using the changeset viewer.