[345] | 1 | require File.dirname(__FILE__) + '/../../../../spec_helper'
|
---|
| 2 | include OpenEHR::RM::Composition
|
---|
| 3 | include OpenEHR::RM::DataTypes::Quantity::DateTime
|
---|
| 4 | include OpenEHR::RM::DataTypes::Text
|
---|
| 5 | include OpenEHR::RM::DataStructures::ItemStructure
|
---|
| 6 |
|
---|
| 7 | describe EventContext do
|
---|
| 8 | before(:each) do
|
---|
| 9 | start = DvDateTime.new(:value => '2009-11-13T20:46:57')
|
---|
| 10 | setting_group = stub(CodePhrase, :code_string => '225')
|
---|
| 11 | setting = stub(DvCodedText, :defining_code => setting_group)
|
---|
| 12 | ending = DvDateTime.new(:value => '2010-10-14T09:00:00')
|
---|
| 13 | participations = stub(Array, :size => 5, :empty? => false)
|
---|
| 14 | other_context = stub(ItemStructure, :archetype_node_id => 'at0002')
|
---|
| 15 | @event_context = EventContext.new(:start_time => start,
|
---|
| 16 | :end_time => ending,
|
---|
| 17 | :setting => setting,
|
---|
| 18 | :participations => participations,
|
---|
| 19 | :location => 'ehime',
|
---|
| 20 | :other_context => other_context)
|
---|
| 21 | end
|
---|
| 22 |
|
---|
| 23 | it 'should be an instance of EventContext' do
|
---|
| 24 | @event_context.should be_an_instance_of EventContext
|
---|
| 25 | end
|
---|
| 26 |
|
---|
| 27 | it 'start_time should be assigned properly' do
|
---|
| 28 | @event_context.start_time.value.should == '2009-11-13T20:46:57'
|
---|
| 29 | end
|
---|
| 30 |
|
---|
| 31 | it 'should raise ArgumentError with nil start_time' do
|
---|
| 32 | lambda {
|
---|
| 33 | @event_context.start_time = nil
|
---|
| 34 | }.should raise_error ArgumentError
|
---|
| 35 | end
|
---|
| 36 |
|
---|
| 37 | it 'setting should be assigned properly' do
|
---|
| 38 | @event_context.setting.defining_code.code_string.should == '225'
|
---|
| 39 | end
|
---|
| 40 |
|
---|
| 41 | it 'should raise ArgumentError with nil setting' do
|
---|
| 42 | lambda {
|
---|
| 43 | @event_context.setting = nil
|
---|
| 44 | }.should raise_error ArgumentError
|
---|
| 45 | end
|
---|
| 46 |
|
---|
| 47 | it 'should vaildate setting code with Terminology service'
|
---|
| 48 |
|
---|
| 49 | it 'end_time should be assigned properly' do
|
---|
| 50 | @event_context.end_time.value.should == '2010-10-14T09:00:00'
|
---|
| 51 | end
|
---|
| 52 |
|
---|
| 53 | it 'participations should be properly assigned' do
|
---|
| 54 | @event_context.participations.size.should be_equal 5
|
---|
| 55 | end
|
---|
| 56 |
|
---|
| 57 | it 'should raise ArgumentError with empty participations' do
|
---|
| 58 | lambda {
|
---|
| 59 | @event_context.participations = [ ]
|
---|
| 60 | }.should raise_error ArgumentError
|
---|
| 61 | end
|
---|
| 62 |
|
---|
| 63 | it 'should not raise ArgumentError with nil participations' do
|
---|
| 64 | lambda {
|
---|
| 65 | @event_context.participations = nil
|
---|
| 66 | }.should_not raise_error ArgumentError
|
---|
| 67 | end
|
---|
| 68 |
|
---|
| 69 | it 'location should be assigned properly' do
|
---|
| 70 | @event_context.location.should == 'ehime'
|
---|
| 71 | end
|
---|
| 72 |
|
---|
| 73 | it 'should raise ArgumentError with empty location' do
|
---|
| 74 | lambda {
|
---|
| 75 | @event_context.location = ''
|
---|
| 76 | }.should raise_error ArgumentError
|
---|
| 77 | end
|
---|
| 78 |
|
---|
| 79 | it 'should not raise ArgumentError with nil location' do
|
---|
| 80 | lambda {
|
---|
| 81 | @event_context.location = nil
|
---|
| 82 | }.should_not raise_error ArgumentError
|
---|
| 83 | end
|
---|
| 84 |
|
---|
| 85 | it 'other_context should be assigned properly' do
|
---|
| 86 | @event_context.other_context.archetype_node_id.should == 'at0002'
|
---|
| 87 | end
|
---|
| 88 | end
|
---|