source: ruby/branches/0.5/spec/lib/open_ehr/rm/composition/composition_spec.rb@ 345

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

fixed #79

File size: 2.9 KB
Line 
1require File.dirname(__FILE__) + '/../../../../spec_helper'
2include OpenEHR::RM::Composition
3include OpenEHR::RM::DataTypes::Text
4include OpenEHR::RM::Support::Identification
5include OpenEHR::RM::Common::Generic
6
7describe Composition do
8 before(:each) do
9 name = DvText.new(:value => 'composition test')
10 language = stub(CodePhrase, :code_string => 'ja')
11 category = stub(DvCodedText, :value => 'event')
12 territory = stub(CodePhrase, :code_string => 'jpn')
13 external_ref = stub(PartyRef, :type => 'ROLE')
14 composer = stub(PartyProxy, :external_ref => external_ref)
15 content = stub(Array, :size => 3)
16 context = stub(EventContext, :location => 'lab1')
17 @composition = Composition.new(:archetype_node_id => 'at0001',
18 :name => name,
19 :language => language,
20 :category => category,
21 :territory => territory,
22 :composer => composer,
23 :content => content,
24 :context => context)
25 end
26
27 it 'should be an instance of Composition' do
28 @composition.should be_an_instance_of Composition
29 end
30
31 it 'language should be assigned properly' do
32 @composition.language.code_string.should == 'ja'
33 end
34
35 it 'should validate language with Termonology service'
36
37 it 'should raise ArgumentError with nil language' do
38 lambda {
39 @composition.language = nil
40 }.should raise_error ArgumentError
41 end
42
43 it 'category should be assigned properly' do
44 @composition.category.value.should == 'event'
45 end
46
47 it 'should validate category with Terminology service'
48
49 it 'should raise ArgumentError with nil category' do
50 lambda {
51 @composition.category = nil
52 }.should raise_error ArgumentError
53 end
54
55 it 'territory should be assined properly' do
56 @composition.territory.code_string.should == 'jpn'
57 end
58
59 it 'should raise ArgumentError with nil territory' do
60 lambda {
61 @composition.territory = nil
62 }.should raise_error ArgumentError
63 end
64
65 it 'composer should be assigned properly' do
66 @composition.composer.external_ref.type.should == 'ROLE'
67 end
68
69 it 'should raise ArgumentError with nil comosser' do
70 lambda {
71 @composition.composer = nil
72 }.should raise_error ArgumentError
73 end
74
75 it 'is_persistent? should be false when category is not persistent' do
76 @composition.is_persistent?.should be_false
77 end
78
79 it 'is_persistent? should be true when category is persistent' do
80 category = stub(DvCodedText, :value => 'persistent')
81 @composition.category = category
82 @composition.is_persistent?.should be_true
83 end
84
85 it 'content should be assigned properly' do
86 @composition.content.size.should == 3
87 end
88
89 it 'context should be assigned properly' do
90 @composition.context.location.should == 'lab1'
91 end
92end
Note: See TracBrowser for help on using the repository browser.