source: ruby/trunk/spec/lib/open_ehr/rm/ehr/ehr_spec.rb@ 369

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

merge from branches/0.5

File size: 4.2 KB
Line 
1require File.dirname(__FILE__) + '/../../../../spec_helper'
2include OpenEHR::RM::EHR
3include OpenEHR::RM::Support::Identification
4include OpenEHR::RM::DataTypes::Quantity::DateTime
5
6describe EHR do
7 before(:each) do
8 system_id = HierObjectID.new(:value => 'ABC::DEF')
9 ehr_id = HierObjectID.new(:value => 'GHI::JKL')
10 time_created = DvDateTime.new(:value => '2009-11-14T19:01:11')
11 ehr_access = stub(ObjectRef, :type => 'VERSIONED_EHR_ACCESS')
12 ehr_status = stub(ObjectRef, :type => 'VERSIONED_EHR_STATUS')
13 contribution1 = stub(ObjectRef, :type => 'CONTRIBUTION')
14 contribution2 = stub(ObjectRef, :type => 'CONTRIBUTION')
15 contributions = [contribution1, contribution2]
16 directory = stub(ObjectRef, :type => 'VERSIONED_FOLDER')
17 composition1 = stub(ObjectRef, :type => 'VERSIONED_COMPOSITION')
18 composition2 = stub(ObjectRef, :type => 'VERSIONED_COMPOSITION')
19 composition3 = stub(ObjectRef, :type => 'VERSIONED_COMPOSITION')
20 compositions = [composition1, composition2, composition3]
21 @ehr = EHR.new(:system_id => system_id,
22 :ehr_id => ehr_id,
23 :time_created => time_created,
24 :contributions => contributions,
25 :ehr_access => ehr_access,
26 :ehr_status => ehr_status,
27 :directory => directory,
28 :compositions => compositions)
29 end
30
31 it 'should be an instance of EHR' do
32 @ehr.should be_an_instance_of EHR
33 end
34
35 it 'system_id should be assigned properly' do
36 @ehr.system_id.value.should == 'ABC::DEF'
37 end
38
39 it 'should raise ArgumentError with nil system_id' do
40 lambda {
41 @ehr.system_id = nil
42 }.should raise_error ArgumentError
43 end
44
45 it 'ehr_id should be assigned properly' do
46 @ehr.ehr_id.value.should == 'GHI::JKL'
47 end
48
49 it 'should raise ArgumentError with nil ehr_id' do
50 lambda {
51 @ehr.ehr_id = nil
52 }.should raise_error ArgumentError
53 end
54
55 it 'time_created should be assigned properly' do
56 @ehr.time_created.value.should == '2009-11-14T19:01:11'
57 end
58
59 it 'should raise ArgumentError with nil time_created' do
60 lambda {
61 @ehr.time_created = nil
62 }.should raise_error ArgumentError
63 end
64
65 it 'contributions should properly assigned' do
66 @ehr.contributions.size.should be_equal 2
67 end
68
69 it 'type contributions should be CONTRIBUTION' do
70 contributions = [stub(ObjectRef, :type => 'PARTY')]
71 lambda {
72 @ehr.contributions = contributions
73 }.should raise_error ArgumentError
74 end
75
76 it 'should raise ArgumentError with nil contributions' do
77 lambda {
78 @ehr.contributions = nil
79 }.should raise_error ArgumentError
80 end
81
82 it 'ehr_access should be assigned properly' do
83 @ehr.ehr_access.type.should == 'VERSIONED_EHR_ACCESS'
84 end
85
86 it 'should raise ArgumentError with nil ehr_access' do
87 lambda {
88 @ehr.ehr_access = nil
89 }.should raise_error ArgumentError
90 end
91
92 it 'should raise ArguemntError with invalid ehr_access type' do
93 lambda {
94 @ehr.ehr_access = stub(ObjectRef, :type => 'VERSIONED_EHR_STATUS')
95 }.should raise_error ArgumentError
96 end
97
98 it 'ehr_status should be assigned properly' do
99 @ehr.ehr_status.type.should == 'VERSIONED_EHR_STATUS'
100 end
101
102 it 'should raise ArgumentError with nil ehr_status' do
103 lambda {
104 @ehr.ehr_status = nil
105 }.should raise_error ArgumentError
106 end
107
108 it 'should raise ArgumentError with invalid ehr_statsu type' do
109 lambda {
110 @ehr.ehr_status = stub(ObjectRef, :type => 'VERSIONED_EHR_ACCESS')
111 }.should raise_error ArgumentError
112 end
113
114 it 'should assigned compositions properly' do
115 @ehr.compositions.size.should be_equal 3
116 end
117
118 it 'should raise ArgumentError with nil compositions' do
119 lambda {
120 @ehr.compositions = nil
121 }.should raise_error ArgumentError
122 end
123
124 it 'should raise ArgumentError with invalid type composition' do
125 lambda {
126 @ehr.compositions = [stub(ObjectRef, :type => 'INVALID_COMPOSITION')]
127 }.should raise_error ArgumentError
128 end
129
130 it 'should assigned directory properly' do
131 @ehr.directory.type.should == 'VERSIONED_FOLDER'
132 end
133
134 it 'should raise ArgumentError with invalid type' do
135 lambda {
136 @ehr.directory = stub(ObjectRef, :type => 'INVALID_FOLDER')
137 }.should raise_error ArgumentError
138 end
139end
Note: See TracBrowser for help on using the repository browser.