Changeset 339 for ruby/branches


Ignore:
Timestamp:
Nov 10, 2009, 9:46:35 PM (14 years ago)
Author:
KOBAYASHI, Shinji
Message:

data_structure will nearly completed

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  
    5454              return item if item.name.value == a_name
    5555            end
    56             retrun nil
     56            return nil
    5757          end
    5858
     
    111111          def ith_row(i)
    112112            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]
    118114          end
    119115
     
    139135              return row if row.items[0].name.value == key
    140136            end
    141             return []
    142137          end
    143138
  • ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_list_spec.rb

    r220 r339  
    3636  end
    3737
    38   it 'retrieve the item with a name' do
     38  it 'should return the item with a name' do
    3939    @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
    4044  end
    4145
  • ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_single_spec.rb

    r216 r339  
    66
    77describe 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')
    1411    @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)
    1814  end
    1915
     16  it 'should be an instance of ItemSingle' do
     17    @item_single.should be_an_instance_of ItemSingle
     18  end
    2019
     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
    2129end
  • ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_table_spec.rb

    r220 r339  
    4545  end
    4646
     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
    4751
    4852  it 's row_names should be cluster cluster' do
     
    96100  end
    97101
     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
    98106  it 'second row should be named_row four' do
    99107    @item_table.named_row('four').items[1].name.value = 'five'
     
    126134
    127135  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
    129142  end
    130143
Note: See TracChangeset for help on using the changeset viewer.