1 | require File.dirname(__FILE__) + '/../../../../../../spec_helper'
|
---|
2 | require File.dirname(__FILE__) + '/shared_examples_spec'
|
---|
3 | include OpenEHR::RM::Composition::Content::Entry
|
---|
4 | include OpenEHR::RM::DataTypes::Text
|
---|
5 | include OpenEHR::RM::Common::Generic
|
---|
6 |
|
---|
7 | describe Entry do
|
---|
8 | it_should_behave_like 'entry'
|
---|
9 |
|
---|
10 | before(:each) do
|
---|
11 | external_ref = stub(PartyRef, :type => 'entry')
|
---|
12 | subject = PartyProxy.new(:external_ref => external_ref)
|
---|
13 | provider_external_ref = stub(PartyRef, :type => 'provider')
|
---|
14 | provider = PartyProxy.new(:external_ref => provider_external_ref)
|
---|
15 | other_participations = stub(Array, :size => 3, :empty? => false)
|
---|
16 | workflow_id = stub(ObjectRef, :type => 'workflow')
|
---|
17 | @entry = Entry.new(:archetype_node_id => 'at0001',
|
---|
18 | :name => DvText.new(:value => 'entry test'),
|
---|
19 | :language => @language,
|
---|
20 | :encoding => @encoding,
|
---|
21 | :subject => subject,
|
---|
22 | :provider => provider,
|
---|
23 | :other_participations => other_participations,
|
---|
24 | :workflow_id => workflow_id)
|
---|
25 | end
|
---|
26 |
|
---|
27 | it 'should be an instance of Entry' do
|
---|
28 | @entry.should be_an_instance_of Entry
|
---|
29 | end
|
---|
30 |
|
---|
31 | it 'language should be assigned properly' do
|
---|
32 | @entry.language.code_string.should == 'ja'
|
---|
33 | end
|
---|
34 |
|
---|
35 | it 'should raise ArgumentError when nil assign to language' do
|
---|
36 | lambda {
|
---|
37 | @entry.language = nil
|
---|
38 | }.should raise_error ArgumentError
|
---|
39 | end
|
---|
40 |
|
---|
41 | it 'should raise ArgumentError with invalid language code'
|
---|
42 |
|
---|
43 | it 'encoding should be assigned properly' do
|
---|
44 | @entry.encoding.code_string.should == 'UTF-8'
|
---|
45 | end
|
---|
46 |
|
---|
47 | it 'should raise ArgumentError when nil assign to encoding' do
|
---|
48 | lambda {
|
---|
49 | @entry.encoding = nil
|
---|
50 | }.should raise_error ArgumentError
|
---|
51 | end
|
---|
52 |
|
---|
53 | it 'should raise ArgumentError with invalid encoding'
|
---|
54 |
|
---|
55 | it 'subject should be assigned properly' do
|
---|
56 | @entry.subject.external_ref.type.should == 'entry'
|
---|
57 | end
|
---|
58 |
|
---|
59 | it 'should raise ArgumentError when nil assigned to subject' do
|
---|
60 | lambda {
|
---|
61 | @entry.subject = nil
|
---|
62 | }.should raise_error ArgumentError
|
---|
63 | end
|
---|
64 |
|
---|
65 | it 'provider should be assigned properly' do
|
---|
66 | @entry.provider.external_ref.type.should == 'provider'
|
---|
67 | end
|
---|
68 |
|
---|
69 | it 'other_participations should be assigned properly' do
|
---|
70 | @entry.other_participations.size.should be_equal 3
|
---|
71 | end
|
---|
72 |
|
---|
73 | it 'workflow_id should assigned properly' do
|
---|
74 | @entry.workflow_id.type.should == 'workflow'
|
---|
75 | end
|
---|
76 |
|
---|
77 | it 'subject_is_self? should be determined by subject class' do
|
---|
78 | @entry.subject_is_self?.should be_false
|
---|
79 | end
|
---|
80 |
|
---|
81 | it 'subject_is_self? should be true when subject is instance of PartySelf' do
|
---|
82 | @entry.subject = PartySelf.new
|
---|
83 | @entry.subject_is_self?.should be_true
|
---|
84 | end
|
---|
85 | end
|
---|