source: ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/history/history_spec.rb@ 343

Last change on this file since 343 was 343, checked in by KOBAYASHI, Shinji, 14 years ago

ref #55
time calculation is difficult

File size: 2.1 KB
Line 
1require File.dirname(__FILE__) + '/../../../../../spec_helper'
2include OpenEHR::RM::DataStructures::History
3include OpenEHR::RM::DataStructures::ItemStructure
4include OpenEHR::RM::DataTypes::Text
5include OpenEHR::RM::DataTypes::Quantity::DateTime
6
7describe History do
8 before(:each) do
9 origin = DvDateTime.new(:value => '2009-11-01T00:00:00')
10 period = DvDuration.new(:value => 'P1Y2M3W4D')
11 duration = DvDuration.new(:value => 'P0Y0M0W6D')
12 events = [stub(Event, :archetype_node_id => 'at0002')]
13 summary = stub(ItemStructure, :archetype_node_id => 'at0003')
14 @history = History.new(:archetype_node_id => 'at0001',
15 :name => DvText.new(:value => 'history test'),
16 :origin => origin,
17 :period => period,
18 :duration => duration,
19 :events => events,
20 :summary => summary)
21 end
22
23 it 'should be an instance of History' do
24 @history.should be_an_instance_of History
25 end
26
27 it 'origin should be properly assigned' do
28 @history.origin.value.should == '2009-11-01T00:00:00'
29 end
30
31 it 'should raise ArgumentError with nil origin' do
32 lambda {
33 @history.origin = nil
34 }.should raise_error ArgumentError
35 end
36
37 it 'period should be properly assigned' do
38 @history.period.value.should == 'P1Y2M3W4D'
39 end
40
41 it 'duration should be properly assigned' do
42 @history.duration.value.should == 'P0Y0M0W6D'
43 end
44
45 it 'is_periodic? should be true when period is not nil' do
46 @history.is_periodic?.should be_true
47 end
48
49 it 'is_periodic? should be false when period is nil' do
50 @history.period = nil
51 @history.is_periodic?.should be_false
52 end
53
54 it 'events should be properly assigned' do
55 @history.events[0].archetype_node_id.should == 'at0002'
56 end
57
58 it 'empty events should raise ArgumentError' do
59 lambda {
60 @history.events = []
61 }.should raise_error ArgumentError
62 end
63
64 it 'summary should be properly assigned' do
65 @history.summary.archetype_node_id.should == 'at0003'
66 end
67end
Note: See TracBrowser for help on using the repository browser.