[338] | 1 | require File.dirname(__FILE__) + '/../../../../../spec_helper'
|
---|
| 2 | include OpenEHR::RM::Common::Resource
|
---|
| 3 |
|
---|
| 4 | describe ResourceDescription do
|
---|
| 5 | before(:each) do
|
---|
| 6 | original_author = {'Shinji KOBAYASHI', 'Ehime University'}
|
---|
| 7 | other_contributors = ['Akimichi TATSUKAWA']
|
---|
| 8 | resource_description_item =
|
---|
| 9 | stub(ResourceDescriptionItem, :purpose => 'test')
|
---|
| 10 | details = {'case', resource_description_item}
|
---|
| 11 | other_details = {'charset', 'UTF-8'}
|
---|
| 12 | parent_resource = stub(AuthoredResource, :current_revision => '0.0.3')
|
---|
| 13 | @resource_description =
|
---|
| 14 | ResourceDescription.new(:original_author => original_author,
|
---|
| 15 | :other_contributors => other_contributors,
|
---|
| 16 | :lifecycle_state => 'initial',
|
---|
| 17 | :details => details,
|
---|
| 18 | :other_details => other_details,
|
---|
| 19 | :resource_package_uri => 'http://openehr.jp/',
|
---|
| 20 | :parent_resource => parent_resource)
|
---|
| 21 | end
|
---|
| 22 |
|
---|
| 23 | it 'should be an instance of ResourceDescription' do
|
---|
| 24 | @resource_description.should be_an_instance_of ResourceDescription
|
---|
| 25 | end
|
---|
| 26 |
|
---|
| 27 | it 'original author should be Shinji KOBAYASHI' do
|
---|
| 28 | @resource_description.original_author.keys[0].should ==
|
---|
| 29 | 'Shinji KOBAYASHI'
|
---|
| 30 | end
|
---|
| 31 |
|
---|
| 32 | it 'other_contributors should be Akimichi TATSUKAWA' do
|
---|
| 33 | @resource_description.other_contributors[0].should ==
|
---|
| 34 | 'Akimichi TATSUKAWA'
|
---|
| 35 | end
|
---|
| 36 |
|
---|
| 37 | it 'lifecycle_state should be initial' do
|
---|
| 38 | @resource_description.lifecycle_state.should == 'initial'
|
---|
| 39 | end
|
---|
| 40 |
|
---|
| 41 | it 'details key should be case' do
|
---|
| 42 | @resource_description.details.keys[0].should == 'case'
|
---|
| 43 | end
|
---|
| 44 |
|
---|
| 45 | it 'other_details value should be charset, UTF-8' do
|
---|
| 46 | @resource_description.other_details.should == {'charset', 'UTF-8'}
|
---|
| 47 | end
|
---|
| 48 |
|
---|
| 49 | it 'resource package uri should be http://openehr.jp/' do
|
---|
| 50 | @resource_description.resource_package_uri.should == 'http://openehr.jp/'
|
---|
| 51 | end
|
---|
| 52 |
|
---|
| 53 | it 'parent_resource current_revision should be 0.0.3' do
|
---|
| 54 | @resource_description.parent_resource.current_revision.should == '0.0.3'
|
---|
| 55 | end
|
---|
| 56 |
|
---|
| 57 | it 'should raise ArgumentError with nil original author' do
|
---|
| 58 | lambda {
|
---|
| 59 | @resource_description.original_author = nil
|
---|
| 60 | }.should raise_error ArgumentError
|
---|
| 61 | end
|
---|
| 62 |
|
---|
| 63 | it 'should raise ArgumentError with nil lifecycle_state' do
|
---|
| 64 | lambda {
|
---|
| 65 | @resource_description.lifecycle_state = nil
|
---|
| 66 | }.should raise_error ArgumentError
|
---|
| 67 | end
|
---|
| 68 |
|
---|
| 69 | it 'should raise ArgumentError with nil details' do
|
---|
| 70 | lambda {
|
---|
| 71 | @resource_description.details = {}
|
---|
| 72 | }.should raise_error ArgumentError
|
---|
| 73 | end
|
---|
| 74 | end
|
---|