1 | require File.dirname(__FILE__) + '/../../../../spec_helper'
|
---|
2 | include OpenEHR::AM::Archetype
|
---|
3 | include OpenEHR::AM::Archetype::ConstraintModel
|
---|
4 | include OpenEHR::AM::Archetype::Ontology
|
---|
5 | include OpenEHR::RM::DataTypes::Text
|
---|
6 | include OpenEHR::RM::Common::Resource
|
---|
7 | include OpenEHR::RM::Support::Identification
|
---|
8 |
|
---|
9 | describe Archetype do
|
---|
10 | before(:each) do
|
---|
11 | original_language = stub(CodePhrase, :code_string => 'ja')
|
---|
12 | archetype_id = ArchetypeID.new(:value => 'openEHR-EHR-SECTION.physical_examination-prenatal.v2')
|
---|
13 | definition = stub(CComplexObject, :rm_type_name => 'SECTION')
|
---|
14 | ontology = stub(ArchetypeOntology, :specialisation_depth => 1)
|
---|
15 | uid = HierObjectID.new(:value => 'ABCD::1')
|
---|
16 | parent_archetype_id = ArchetypeID.new(:value => 'openEHR-EHR-SECTION.physical_examination.v1')
|
---|
17 | invariants = stub(Set, :size => 2)
|
---|
18 | @archetype = Archetype.new(:original_language => original_language,
|
---|
19 | :adl_version => '1.4',
|
---|
20 | :archetype_id => archetype_id,
|
---|
21 | :concept => 'at0000',
|
---|
22 | :definition => definition,
|
---|
23 | :ontology => ontology,
|
---|
24 | :uid => uid,
|
---|
25 | :parent_archetype_id => parent_archetype_id,
|
---|
26 | :invariants => invariants)
|
---|
27 | end
|
---|
28 |
|
---|
29 | it 'should be an instance of Archetype' do
|
---|
30 | @archetype.should be_an_instance_of Archetype
|
---|
31 | end
|
---|
32 |
|
---|
33 | it 'adl_version should be assigned properly' do
|
---|
34 | @archetype.adl_version.should == '1.4'
|
---|
35 | end
|
---|
36 |
|
---|
37 | it 'archetype_id should be assigned prorperly' do
|
---|
38 | @archetype.archetype_id.value.should == 'openEHR-EHR-SECTION.physical_examination-prenatal.v2'
|
---|
39 | end
|
---|
40 |
|
---|
41 | it 'should raise ArgumentError when archetype_id is nil' do
|
---|
42 | lambda {
|
---|
43 | @archetype.archetype_id = nil
|
---|
44 | }.should raise_error ArgumentError
|
---|
45 | end
|
---|
46 |
|
---|
47 | it 'uid should be assigned properly' do
|
---|
48 | @archetype.uid.value.should == 'ABCD::1'
|
---|
49 | end
|
---|
50 |
|
---|
51 | it 'concept should be assigned properly' do
|
---|
52 | @archetype.concept.should == 'at0000'
|
---|
53 | end
|
---|
54 |
|
---|
55 | it 'should raise ArgumentError when concept is nil' do
|
---|
56 | lambda {
|
---|
57 | @archetype.concept = nil
|
---|
58 | }.should raise_error ArgumentError
|
---|
59 | end
|
---|
60 |
|
---|
61 | it 'parent_archetype_id should be assigned properly' do
|
---|
62 | @archetype.parent_archetype_id.value.should == 'openEHR-EHR-SECTION.physical_examination.v1'
|
---|
63 | end
|
---|
64 |
|
---|
65 | it 'definition should be assigned properly' do
|
---|
66 | @archetype.definition.rm_type_name.should == 'SECTION'
|
---|
67 | end
|
---|
68 |
|
---|
69 | it 'should raise ArgumentError when definition is nil' do
|
---|
70 | lambda {
|
---|
71 | @archetype.definition = nil
|
---|
72 | }.should raise_error ArgumentError
|
---|
73 | end
|
---|
74 |
|
---|
75 | it 'ontology should be assigned properly' do
|
---|
76 | @archetype.ontology.specialisation_depth.should be_equal 1
|
---|
77 | end
|
---|
78 |
|
---|
79 | it 'should raise ArgumentError when ontology is nil' do
|
---|
80 | lambda {
|
---|
81 | @archetype.ontology = nil
|
---|
82 | }.should raise_error ArgumentError
|
---|
83 | end
|
---|
84 |
|
---|
85 | it 'invariants should be assigned properly' do
|
---|
86 | @archetype.invariants.size.should be_equal 2
|
---|
87 | end
|
---|
88 |
|
---|
89 | it 'version should be extracted form id' do
|
---|
90 | @archetype.version.should == 'v2'
|
---|
91 | end
|
---|
92 |
|
---|
93 | it 'short concept name should be extracted from archetype id' do
|
---|
94 | @archetype.short_concept_name.should == 'physical_examination'
|
---|
95 | end
|
---|
96 |
|
---|
97 | it 'concept name should be extracted from ontology'
|
---|
98 | end
|
---|