source: ruby/branches/0.5/spec/lib/open_ehr/rm/composition/content/entry/entry_spec.rb@ 353

Last change on this file since 353 was 353, checked in by KOBAYASHI, Shinji, 14 years ago

refs #57 entry class implementation

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