[332] | 1 | require File.dirname(__FILE__) + '/../../../../../spec_helper'
|
---|
| 2 | include OpenEHR::RM::Common::ChangeControl
|
---|
| 3 | include OpenEHR::RM::Common::Generic
|
---|
| 4 | include OpenEHR::RM::DataTypes::Text
|
---|
| 5 |
|
---|
| 6 | describe Version do
|
---|
| 7 | before(:each) do
|
---|
| 8 | uid = ObjectVersionID.new(:value => 'ABCD::EFG::2')
|
---|
| 9 | preceding_version_uid = ObjectVersionID.new(:value =>'HIJ::KLM::1')
|
---|
| 10 | commit_audit = stub(AuditDetails, :committer => 'UNKNOWN', :empty? => false)
|
---|
| 11 | object_id = stub(ObjectID, :value => 'unique')
|
---|
| 12 | contribution = ObjectRef.new(:namespace => 'local',
|
---|
| 13 | :type => 'CONTRIBUTION',
|
---|
| 14 | :id => object_id)
|
---|
| 15 | defining_code = stub(CodePhrase, :code_string => '532')
|
---|
| 16 | lifecycle_state = stub(DvCodedText, :defining_code => defining_code)
|
---|
| 17 | signature = '4760271533c2866579dde347ad28dd79e4aad933'
|
---|
| 18 | @version = Version.new(:uid => uid,
|
---|
| 19 | :preceding_version_uid => preceding_version_uid,
|
---|
| 20 | :data => 'data',
|
---|
| 21 | :contribution => contribution,
|
---|
| 22 | :lifecycle_state => lifecycle_state,
|
---|
| 23 | :commit_audit => commit_audit,
|
---|
| 24 | :signature => signature)
|
---|
| 25 | end
|
---|
| 26 |
|
---|
| 27 | it 'should be an instance of Version' do
|
---|
| 28 | @version.should be_an_instance_of Version
|
---|
| 29 | end
|
---|
| 30 |
|
---|
| 31 | it 'uid value should be ABCD::EFG::1' do
|
---|
| 32 | @version.uid.value.should == 'ABCD::EFG::2'
|
---|
| 33 | end
|
---|
| 34 |
|
---|
| 35 | it 'commit_audit.committer.should be UNKNOWN' do
|
---|
| 36 | @version.commit_audit.committer.should == 'UNKNOWN'
|
---|
| 37 | end
|
---|
| 38 |
|
---|
| 39 | it 'lifecycle_state should be 532' do
|
---|
| 40 | @version.lifecycle_state.defining_code.code_string.should == '532'
|
---|
| 41 | end
|
---|
| 42 |
|
---|
| 43 | it 'contribution namespece should be local' do
|
---|
| 44 | @version.contribution.namespace.should == 'local'
|
---|
| 45 | end
|
---|
| 46 |
|
---|
| 47 | it 'contribution type should be CONTRIBUTION' do
|
---|
| 48 | contribution = @version.contribution
|
---|
| 49 | contribution.type = 'PARTY'
|
---|
| 50 | lambda {
|
---|
| 51 | @version.contribution = contribution
|
---|
| 52 | }.should raise_error ArgumentError
|
---|
| 53 | end
|
---|
| 54 |
|
---|
| 55 | it 'signature should be 4760271533c2866579dde347ad28dd79e4aad933' do
|
---|
| 56 | @version.signature.should == '4760271533c2866579dde347ad28dd79e4aad933'
|
---|
| 57 | end
|
---|
| 58 |
|
---|
| 59 | it 'should not be a branch' do
|
---|
| 60 | @version.is_branch?.should_not be true
|
---|
| 61 | end
|
---|
| 62 |
|
---|
| 63 | it 'should be a branch' do
|
---|
| 64 | @version.uid.value = 'ABCD::EFG::1.2.3'
|
---|
| 65 | @version.is_branch?.should be true
|
---|
| 66 | end
|
---|
| 67 |
|
---|
| 68 | it 'data should be data' do
|
---|
| 69 | @version.data.should == 'data'
|
---|
| 70 | end
|
---|
| 71 |
|
---|
| 72 | it 'owner_id value should be ABCD::EFG::2' do
|
---|
| 73 | @version.owner_id.value.should == 'ABCD::EFG::2'
|
---|
| 74 | end
|
---|
| 75 |
|
---|
| 76 | it 'canonical form is not well determined' do
|
---|
| 77 | lambda {
|
---|
| 78 | @version.canonical_form
|
---|
| 79 | }.should raise_error NotImplementedError
|
---|
| 80 | end
|
---|
| 81 |
|
---|
| 82 | it 'should raise ArgumentError when preceding version id exists and uid version tree is first' do
|
---|
| 83 | @version.uid.value = 'ABC::DEF::1'
|
---|
| 84 | preceding_version_uid = ObjectVersionID.new(:value => 'GHI::JKL::2')
|
---|
| 85 | lambda {
|
---|
| 86 | @version.preceding_version_uid = preceding_version_uid
|
---|
| 87 | }.should raise_error ArgumentError
|
---|
| 88 | end
|
---|
| 89 | end
|
---|