source: ruby/branches/0.5/spec/lib/open_ehr/rm/ehr/ehr_spec.rb@ 348

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

refs #44

File size: 4.1 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 'ehr_access should be assigned properly' do
77 @ehr.ehr_access.type.should == 'VERSIONED_EHR_ACCESS'
78 end
79
80 it 'should raise ArgumentError with nil ehr_access' do
81 lambda {
82 @ehr.ehr_access = nil
83 }.should raise_error ArgumentError
84 end
85
86 it 'should raise ArguemntError with invalid ehr_access type' do
87 lambda {
88 @ehr.ehr_access = stub(ObjectRef, :type => 'VERSIONED_EHR_STATUS')
89 }.should raise_error ArgumentError
90 end
91
92 it 'ehr_status should be assigned properly' do
93 @ehr.ehr_status.type.should == 'VERSIONED_EHR_STATUS'
94 end
95
96 it 'should raise ArgumentError with nil ehr_status' do
97 lambda {
98 @ehr.ehr_status = nil
99 }.should raise_error ArgumentError
100 end
101
102 it 'should raise ArgumentError with invalid ehr_statsu type' do
103 lambda {
104 @ehr.ehr_status = stub(ObjectRef, :type => 'VERSIONED_EHR_ACCESS')
105 }.should raise_error ArgumentError
106 end
107
108 it 'should assigned compositions properly' do
109 @ehr.compositions.size.should be_equal 3
110 end
111
112 it 'should raise ArgumentError with nil compositions' do
113 lambda {
114 @ehr.compositions = nil
115 }.should raise_error ArgumentError
116 end
117
118 it 'should raise ArgumentError with invalid type composition' do
119 lambda {
120 @ehr.compositions = [stub(ObjectRef, :type => 'INVALID_COMPOSITION')]
121 }.should raise_error ArgumentError
122 end
123
124 it 'should assigned directory properly' do
125 @ehr.directory.type.should == 'VERSIONED_FOLDER'
126 end
127
128 it 'should raise ArgumentError with invalid type' do
129 lambda {
130 @ehr.directory = stub(ObjectRef, :type => 'INVALID_FOLDER')
131 }.should raise_error ArgumentError
132 end
133end
Note: See TracBrowser for help on using the repository browser.