1 | require File.dirname(__FILE__) + '/../../../../spec_helper'
|
---|
2 | include OpenEHR::RM::Demographic
|
---|
3 | include OpenEHR::RM::DataTypes::Text
|
---|
4 | include OpenEHR::RM::DataTypes::Quantity::DateTime
|
---|
5 | include OpenEHR::RM::Support::Identification
|
---|
6 | include OpenEHR::RM::DataStructures::ItemStructure
|
---|
7 |
|
---|
8 | describe PartyRelationship do
|
---|
9 | before(:each) do
|
---|
10 | name = DvText.new(:value => 'party relation')
|
---|
11 | uid = HierObjectID.new(:value => '01')
|
---|
12 | details = stub(ItemStructure, :archetype_node_id => 'at0002')
|
---|
13 | upper = DvDate.new(:value => '2009-11-21')
|
---|
14 | time_validity = stub(DvInterval, :upper => upper)
|
---|
15 | source_id = ObjectID.new(:value => '01')
|
---|
16 | source = stub(PartyRef, :id => source_id, :type => 'source')
|
---|
17 | target_id = ObjectID.new(:value => '02')
|
---|
18 | target = stub(PartyRef, :id => target_id)
|
---|
19 | @party_relationship =
|
---|
20 | PartyRelationship.new(:archetype_node_id => 'at0000',
|
---|
21 | :name => name,
|
---|
22 | :uid => uid,
|
---|
23 | :details => details,
|
---|
24 | :time_validity => time_validity,
|
---|
25 | :source => source,
|
---|
26 | :target => target)
|
---|
27 | end
|
---|
28 |
|
---|
29 | it 'should be an instance of PartyRelationship' do
|
---|
30 | @party_relationship.should be_an_instance_of PartyRelationship
|
---|
31 | end
|
---|
32 |
|
---|
33 | it 'uid should be assigned properly' do
|
---|
34 | @party_relationship.uid.value.should == '01'
|
---|
35 | end
|
---|
36 |
|
---|
37 | it 'should raise ArgumentError when nil assigned to uid' do
|
---|
38 | lambda {
|
---|
39 | @party_relationship.uid = nil
|
---|
40 | }.should raise_error ArgumentError
|
---|
41 | end
|
---|
42 |
|
---|
43 | it 'details should be assigned properly' do
|
---|
44 | @party_relationship.details.archetype_node_id.should == 'at0002'
|
---|
45 | end
|
---|
46 |
|
---|
47 | it 'time_validity should be assigned properly' do
|
---|
48 | @party_relationship.time_validity.upper.value.should == '2009-11-21'
|
---|
49 | end
|
---|
50 |
|
---|
51 | it 'source should be_assigned properly' do
|
---|
52 | @party_relationship.source.type.should == 'source'
|
---|
53 | end
|
---|
54 |
|
---|
55 | it 'should raise ArgumentError when source is assinged nil' do
|
---|
56 | lambda {
|
---|
57 | @party_relationship.source = nil
|
---|
58 | }.should raise_error ArgumentError
|
---|
59 | end
|
---|
60 |
|
---|
61 | it 'should raise ArgumentError when source is not matched with source' do
|
---|
62 | invalid_id = ObjectID.new(:value => '10')
|
---|
63 | invalid_source = stub(PartyRef, :id => invalid_id)
|
---|
64 | lambda {
|
---|
65 | @party_relationship.source = invalid_source
|
---|
66 | }.should raise_error ArgumentError
|
---|
67 | end
|
---|
68 |
|
---|
69 | it 'target should be assined properly' do
|
---|
70 | @party_relationship.target.id.value.should == '02'
|
---|
71 | end
|
---|
72 |
|
---|
73 | it 'should raise ArgumentError with target is assigned by nil' do
|
---|
74 | lambda {
|
---|
75 | @party_relationship.target =nil
|
---|
76 | }.should raise_error ArgumentError
|
---|
77 | end
|
---|
78 |
|
---|
79 | it 'type should be inherited of name' do
|
---|
80 | @party_relationship.type.value.should == 'party relation'
|
---|
81 | end
|
---|
82 | end
|
---|
83 |
|
---|
84 |
|
---|