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, 14 years ago

item structure is completed

File size: 1.4 KB
Line 
1require File.dirname(__FILE__) + '/../../../../../spec_helper'
2
3include OpenEHR::RM::DataStructures::ItemStructure
4include OpenEHR::RM::DataStructures::ItemStructure::Representation
5include OpenEHR::RM::DataTypes::Text
6
7describe ItemTree do
8 before(:each) do
9 i = 1
10 items = %w{one two three}.collect do |name|
11 i += 1
12 Element.new(:name => DvText.new(:value => name),
13 :archetype_node_id => 'at000' + i.to_s)
14 end
15 name = DvText.new(:value => 'item tree')
16 @item_tree = ItemTree.new(:name => name,
17 :archetype_node_id => 'at0001',
18 :items => items)
19 end
20
21 it 'should be an instance of ItemTree' do
22 @item_tree.should be_an_instance_of ItemTree
23 end
24
25 it 'first item name should be one' do
26 @item_tree.items[0].name.value.should == 'one'
27 end
28
29 it 'has valid element path' do
30 @item_tree.has_element_path?('at0002').should be_true
31 end
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
48end
Note: See TracBrowser for help on using the repository browser.