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