source: ruby/branches/0.5/spec/lib/open_ehr/rm/common/resource/authored_resource_spec.rb@ 338

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

test/unit for referece models are replaced to rspec.

File size: 2.3 KB
Line 
1require File.dirname(__FILE__) + '/../../../../../spec_helper'
2include OpenEHR::RM::Common::Resource
3include OpenEHR::RM::Common::ChangeControl
4include OpenEHR::RM::DataTypes::Text
5
6describe AuthoredResource do
7 before(:each) do
8 original_language = stub(CodePhrase, :code_string => 'ja')
9 translation_language = stub(CodePhrase, :code_string => 'en')
10 translation_details = stub(TranslationDetails,
11 :language => translation_language)
12 translations = Hash['en', translation_details]
13 description = stub(ResourceDescription, :lifecycle_state => 'initial')
14 revision_history = stub(RevisionHistory, :most_recent_version => '0.0.3')
15 languages_available = Set.new %w(ja en)
16 @authored_resource = AuthoredResource.new(
17 :original_language => original_language,
18 :translations => translations,
19 :description => description,
20 :revision_history => revision_history)
21 end
22
23 it 'should be an instance of AuthoredResource' do
24 @authored_resource.should be_an_instance_of AuthoredResource
25 end
26
27 it 'original language should be ja' do
28 @authored_resource.original_language.code_string.should == 'ja'
29 end
30
31 it 'translations hash en returns en detail' do
32 @authored_resource.translations['en'].language.code_string.should == 'en'
33 end
34
35 it 'description lifecycle_state should e initial' do
36 @authored_resource.description.lifecycle_state.should == 'initial'
37 end
38
39 it 'language_available should be Set(%(ja en))' do
40 languages_set = Set.new ['ja', 'en']
41 @authored_resource.languages_available.should == languages_set
42 end
43
44 it 'current_revision should be 0.0.3' do
45 @authored_resource.current_revision.should == '0.0.3'
46 end
47
48 it 'should be controlled' do
49 @authored_resource.is_controlled?.should be_true
50 end
51
52 it 'should not be controlled' do
53 @authored_resource.revision_history = nil
54 @authored_resource.is_controlled?.should be_false
55 end
56
57 it 'should raise ArgumentError with empty translations' do
58 lambda {
59 @authored_resource.translations = Array.new
60 }.should raise_error ArgumentError
61 end
62
63 it 'should raise ArgumentError when original language is nil' do
64 lambda {
65 @authored_resource.original_language = nil
66 }.should raise_error ArgumentError
67 end
68end
Note: See TracBrowser for help on using the repository browser.