1 | require File.dirname(__FILE__) + '/../../../../../spec_helper'
|
---|
2 |
|
---|
3 | include OpenEhr::RM::DataStructures::ItemStructure
|
---|
4 | include OpenEhr::RM::DataStructures::ItemStructure::Representation
|
---|
5 | include OpenEhr::RM::DataTypes::Text
|
---|
6 |
|
---|
7 | def row(args)
|
---|
8 | return args.collect do |n|
|
---|
9 | Element.new(:name => DvText.new(n),
|
---|
10 | :archetype_node_id => 'test')
|
---|
11 | end
|
---|
12 | end
|
---|
13 |
|
---|
14 | def cluster_builder(name,rows)
|
---|
15 | return Cluster.new(:name => DvText.new(name),
|
---|
16 | :archetype_node_id => 'test',
|
---|
17 | :items => rows)
|
---|
18 | end
|
---|
19 |
|
---|
20 | describe ItemTable do
|
---|
21 | before(:each) do
|
---|
22 | row1 = row(%w{one two three})
|
---|
23 | row2 = row(%w{four five six})
|
---|
24 | rows = [row1, row2].collect{|r| cluster_builder('cluster',r)}
|
---|
25 | @item_table = ItemTable.new(:name => DvText.new('item table'),
|
---|
26 | :archetype_node_id => 'test',
|
---|
27 | :rows => rows)
|
---|
28 | end
|
---|
29 |
|
---|
30 | it 'should be an instance of ItemTable' do
|
---|
31 | @item_table.should be_an_instance_of ItemTable
|
---|
32 | end
|
---|
33 |
|
---|
34 | it 'row count should be 2' do
|
---|
35 | @item_table.row_count.should be_equal 2
|
---|
36 | end
|
---|
37 |
|
---|
38 | it 'column_count should be 3' do
|
---|
39 | @item_table.column_count.should be_equal 3
|
---|
40 | end
|
---|
41 |
|
---|
42 | it 'row_names should be cluster cluster' do
|
---|
43 | @item_table.row_names.should == %w{cluster cluster}.collect{|n| DvText.new(n)}
|
---|
44 | end
|
---|
45 | end
|
---|