source: ruby/branches/0.5/spec/lib/openehr/rm/data_structure/item_structure/item_list_spec.rb@ 195

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

refs #54

File size: 1.3 KB
RevLine 
[193]1require File.dirname(__FILE__) + '/../../../../../spec_helper'
2include OpenEhr::RM::DataStructures::ItemStructure
[195]3include OpenEhr::RM::DataStructures::ItemStructure::Representation
[193]4include OpenEhr::RM::DataTypes::Text
5
6describe ItemList do
7 before(:each) do
[195]8 items = %w{one two three}.collect do |n|
9 Element.new(:name => DvText.new(n),
10 :archetype_node_id => 'test')
11 end
[193]12 item_list_name = DvText.new('item list')
13 @item_list = ItemList.new(:name => item_list_name,
[195]14 :archetype_node_id => 'test',
15 :items => items)
16
[193]17 end
18
[194]19 it 'should be instance of ItemList' do
20 @item_list.should be_an_instance_of ItemList
[193]21 end
[194]22
[195]23 it 'count should be 3' do
24 @item_list.item_count.should be_equal 3
25 end
26
[194]27 it 'count should be 0' do
[195]28 @item_list.items = nil
29 @item_list.item_count.should be_equal 0
[194]30 end
31
[195]32
33 it 'retrieve the names of all items' do
34 @item_list.names.should == %w{one two three}.collect{|n| DvText.new(n)}
[194]35 end
[195]36
37 it 'retrieve the item with a name' do
38 @item_list.named_item('one').name.value.should == 'one'
39 end
40
41 it 'retrieve the ith item with number' do
42 @item_list.ith_item(1).name.value.should == 'two'
43 end
44
45 it 'generate cluster of items' do
46 @item_list.as_hierarchy.name.value.should == 'item list'
47 end
[193]48end
Note: See TracBrowser for help on using the repository browser.