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