source: ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_tree_spec.rb

Last change on this file was 340, checked in by KOBAYASHI, Shinji, 15 years ago

item structure is completed

File size: 1.4 KB
RevLine 
[214]1require File.dirname(__FILE__) + '/../../../../../spec_helper'
2
[216]3include OpenEHR::RM::DataStructures::ItemStructure
4include OpenEHR::RM::DataStructures::ItemStructure::Representation
5include OpenEHR::RM::DataTypes::Text
[214]6
7describe ItemTree do
8 before(:each) do
[340]9 i = 1
10 items = %w{one two three}.collect do |name|
11 i += 1
[220]12 Element.new(:name => DvText.new(:value => name),
[340]13 :archetype_node_id => 'at000' + i.to_s)
[215]14 end
[220]15 name = DvText.new(:value => 'item tree')
[214]16 @item_tree = ItemTree.new(:name => name,
[340]17 :archetype_node_id => 'at0001',
[215]18 :items => items)
[214]19 end
20
21 it 'should be an instance of ItemTree' do
22 @item_tree.should be_an_instance_of ItemTree
23 end
[215]24
[216]25 it 'first item name should be one' do
[215]26 @item_tree.items[0].name.value.should == 'one'
27 end
[216]28
29 it 'has valid element path' do
[340]30 @item_tree.has_element_path?('at0002').should be_true
[216]31 end
[340]32
33 it 'should return false with wrong node' do
34 @item_tree.has_element_path?('at0005').should be_false
35 end
36
37 it 'path at002 should return two' do
38 @item_tree.element_at_path('at0003').name.value.should == 'two'
39 end
40
41 it 'path at005 should return nil' do
42 @item_tree.element_at_path('at0005').should be_nil
43 end
44
45 it 'should returns ItemTree as Cluster' do
46 @item_tree.as_hierarchy.name.value.should == 'item tree'
47 end
[214]48end
Note: See TracBrowser for help on using the repository browser.