1 | require File.dirname(__FILE__) + '/../../../../../spec_helper'
|
---|
2 | include OpenEHR::RM::Common::ChangeControl
|
---|
3 | include OpenEHR::RM::DataTypes::Text
|
---|
4 |
|
---|
5 | describe OriginalVersion do
|
---|
6 | before(:each) do
|
---|
7 | uid = ObjectVersionID.new(:value => 'ABC::DEF::1')
|
---|
8 | defining_code = stub(CodePhrase, :code_string => '532')
|
---|
9 | lifecycle_state = stub(DvCodedText, :defining_code => defining_code)
|
---|
10 | object_id = stub(ObjectID, :value => 'unique')
|
---|
11 | contribution = ObjectRef.new(:namespace => 'local',
|
---|
12 | :type => 'CONTRIBUTION',
|
---|
13 | :id => object_id)
|
---|
14 | commit_audit = stub(AuditDetails, :committer => 'UNKNOWN', :empty? => false)
|
---|
15 | attestations = stub(Array, :empty? => false, :size => 12)
|
---|
16 | other_input_version_uids = stub(Set, :empty? => false, :size => 5)
|
---|
17 | @original_version = OriginalVersion.new(:uid => uid,
|
---|
18 | :lifecycle_state => lifecycle_state,
|
---|
19 | :attestations => attestations,
|
---|
20 | :commit_audit => commit_audit,
|
---|
21 | :contribution => contribution,
|
---|
22 | :other_input_version_uids => other_input_version_uids)
|
---|
23 | end
|
---|
24 |
|
---|
25 | it 'should be an isntance of OriginalVersion' do
|
---|
26 | @original_version.should be_an_instance_of OriginalVersion
|
---|
27 | end
|
---|
28 |
|
---|
29 | it 'attestation size should be 12' do
|
---|
30 | @original_version.attestations.size.should == 12
|
---|
31 | end
|
---|
32 |
|
---|
33 | it 'other_version_input_uids size should be 5' do
|
---|
34 | @original_version.other_input_version_uids.size.should == 5
|
---|
35 | end
|
---|
36 |
|
---|
37 | it 'is_merged? should be true when other_input_version_uids is nil' do
|
---|
38 | @original_version.is_merged?.should be_true
|
---|
39 | end
|
---|
40 |
|
---|
41 | it 'is_merged? should not be true when other_input_version_uids is not nil' do
|
---|
42 | @original_version.other_input_version_uids = nil
|
---|
43 | @original_version.is_merged?.should be_false
|
---|
44 | end
|
---|
45 |
|
---|
46 | it 'should raise ArgumentError when attestations is nil' do
|
---|
47 | lambda {
|
---|
48 | @original_version.attestations = nil
|
---|
49 | }.should raise_error ArgumentError
|
---|
50 | end
|
---|
51 |
|
---|
52 | it 'should raise ArgumentError when other_input_version_uids is empty' do
|
---|
53 | lambda {
|
---|
54 | @original_version.other_input_version_uids = Set.new
|
---|
55 | }.should raise_error ArgumentError
|
---|
56 | end
|
---|
57 | end
|
---|