Changeset 339
- Timestamp:
- Nov 10, 2009, 9:46:35 PM (14 years ago)
- Location:
- ruby/branches/0.5
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
ruby/branches/0.5/lib/open_ehr/rm/data_structures/item_structure.rb
r216 r339 54 54 return item if item.name.value == a_name 55 55 end 56 ret run nil56 return nil 57 57 end 58 58 … … 111 111 def ith_row(i) 112 112 raise ArgumentError, 'invalid index' if i<=0 or i>@rows.size 113 if @rows.nil? 114 return [] 115 else 116 return @rows[i - 1] 117 end 113 return @rows[i - 1] 118 114 end 119 115 … … 139 135 return row if row.items[0].name.value == key 140 136 end 141 return []142 137 end 143 138 -
ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_list_spec.rb
r220 r339 36 36 end 37 37 38 it ' retrievethe item with a name' do38 it 'should return the item with a name' do 39 39 @item_list.named_item('one').name.value.should == 'one' 40 end 41 42 it 'should return nil when item is not exist' do 43 @item_list.named_item('four').should be_nil 40 44 end 41 45 -
ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_single_spec.rb
r216 r339 6 6 7 7 describe ItemSingle do 8 before(:all) do 9 name = 10 @element = Element.new(:name => DvText.new('item'), 11 :archetype_node_id => 'AT0000', 12 :value => DvQuantity.new()) 13 item_single_name = DvText.new('item single') 8 before(:each) do 9 element = stub(Element, :archetype_node_id => 'at0002') 10 item_single_name = DvText.new(:value => 'item single') 14 11 @item_single = ItemSingle.new(:name => item_single_name, 15 :archetype_node_id => 'test', 16 :item => @element) 17 12 :archetype_node_id => 'at0001', 13 :item => element) 18 14 end 19 15 16 it 'should be an instance of ItemSingle' do 17 @item_single.should be_an_instance_of ItemSingle 18 end 20 19 20 it 'should raise ArgumentError with nil item' do 21 lambda { 22 @item_single.item = nil 23 }.should raise_error ArgumentError 24 end 25 26 it 'should return as_hierarchy' do 27 @item_single.as_hierarchy.archetype_node_id.should == 'at0002' 28 end 21 29 end -
ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_table_spec.rb
r220 r339 45 45 end 46 46 47 it 'column_count should be 0 when @rows == nil' do 48 @item_table.rows = nil 49 @item_table.column_count.should be_equal 0 50 end 47 51 48 52 it 's row_names should be cluster cluster' do … … 96 100 end 97 101 102 it 'should be false it has_column with name ten' do 103 @item_table.has_column_with_name?('ten').should be_false 104 end 105 98 106 it 'second row should be named_row four' do 99 107 @item_table.named_row('four').items[1].name.value = 'five' … … 126 134 127 135 it 'should be two element at named cell by row column' do 128 @item_table.element_at_named_cell('cluster', 'two').name.value == 'two' 136 @item_table.element_at_named_cell('cluster', 'three').name.value == 'three' 137 end 138 139 it 'should return nil when rows are nil' do 140 @item_table.rows = nil 141 @item_table.row_count.should be_equal 0 129 142 end 130 143
Note:
See TracChangeset
for help on using the changeset viewer.