require File.dirname(__FILE__) + '/../../../../../spec_helper' include OpenEHR::RM::Common::ChangeControl include OpenEHR::RM::DataTypes::Text describe OriginalVersion do before(:each) do uid = ObjectVersionID.new(:value => 'ABC::DEF::1') defining_code = stub(CodePhrase, :code_string => '532') lifecycle_state = stub(DvCodedText, :defining_code => defining_code) object_id = stub(ObjectID, :value => 'unique') contribution = ObjectRef.new(:namespace => 'local', :type => 'CONTRIBUTION', :id => object_id) commit_audit = stub(AuditDetails, :committer => 'UNKNOWN', :empty? => false) attestations = stub(Array, :empty? => false, :size => 12) other_input_version_uids = stub(Set, :empty? => false, :size => 5) @original_version = OriginalVersion.new(:uid => uid, :lifecycle_state => lifecycle_state, :attestations => attestations, :commit_audit => commit_audit, :contribution => contribution, :other_input_version_uids => other_input_version_uids) end it 'should be an isntance of OriginalVersion' do @original_version.should be_an_instance_of OriginalVersion end it 'attestation size should be 12' do @original_version.attestations.size.should == 12 end it 'other_version_input_uids size should be 5' do @original_version.other_input_version_uids.size.should == 5 end it 'is_merged? should be true when other_input_version_uids is nil' do @original_version.is_merged?.should be_true end it 'is_merged? should not be true when other_input_version_uids is not nil' do @original_version.other_input_version_uids = nil @original_version.is_merged?.should be_false end it 'should raise ArgumentError when attestations is nil' do lambda { @original_version.attestations = nil }.should raise_error ArgumentError end it 'should raise ArgumentError when other_input_version_uids is empty' do lambda { @original_version.other_input_version_uids = Set.new }.should raise_error ArgumentError end end