1 | require File.dirname(__FILE__) + '/../../../../../../spec_helper'
|
---|
2 | require File.dirname(__FILE__) + '/shared_examples_spec'
|
---|
3 | include OpenEHR::RM::Composition::Content::Entry
|
---|
4 | include OpenEHR::RM::DataTypes::Quantity::DateTime
|
---|
5 | include OpenEHR::RM::DataTypes::Text
|
---|
6 | include OpenEHR::RM::DataStructures::ItemStructure
|
---|
7 |
|
---|
8 | describe Action do
|
---|
9 | it_should_behave_like 'entry'
|
---|
10 |
|
---|
11 | before(:each) do
|
---|
12 | time = DvDateTime.new(:value => '2009-11-18T20:17:18')
|
---|
13 | description = stub(ItemStructure, :archetype_node_id => 'at0002')
|
---|
14 | current_state = stub(DvCodedText, :value => 'planned')
|
---|
15 | ism_transition = stub(IsmTransition, :current_state => current_state)
|
---|
16 | instruction_details = stub(InstructionDetails, :activity_id => 'at0003')
|
---|
17 | @action= Action.new(:archetype_node_id => 'at0001',
|
---|
18 | :name => @name,
|
---|
19 | :language => @language,
|
---|
20 | :encoding => @encoding,
|
---|
21 | :subject => @subject,
|
---|
22 | :time => time,
|
---|
23 | :description => description,
|
---|
24 | :ism_transition => ism_transition,
|
---|
25 | :instruction_details => instruction_details)
|
---|
26 | end
|
---|
27 |
|
---|
28 | it 'should be an instance of Action' do
|
---|
29 | @action.should be_an_instance_of Action
|
---|
30 | end
|
---|
31 |
|
---|
32 | it 'time should be assigned properly' do
|
---|
33 | @action.time.value.should == '2009-11-18T20:17:18'
|
---|
34 | end
|
---|
35 |
|
---|
36 | it 'should raise ArgumentError with nil assigned to time' do
|
---|
37 | lambda {
|
---|
38 | @action.time = nil
|
---|
39 | }.should raise_error ArgumentError
|
---|
40 | end
|
---|
41 |
|
---|
42 | it 'description should assigned properly' do
|
---|
43 | @action.description.archetype_node_id.should == 'at0002'
|
---|
44 | end
|
---|
45 |
|
---|
46 | it 'should raise ArgumentError with nil description' do
|
---|
47 | lambda {
|
---|
48 | @action.description = nil
|
---|
49 | }.should raise_error ArgumentError
|
---|
50 | end
|
---|
51 |
|
---|
52 | it 'ism_transition should be assigned properly' do
|
---|
53 | @action.ism_transition.current_state.value.should == 'planned'
|
---|
54 | end
|
---|
55 |
|
---|
56 | it 'should raise ArgumentError with nil ism_transition' do
|
---|
57 | lambda {
|
---|
58 | @action.ism_transition = nil
|
---|
59 | }.should raise_error ArgumentError
|
---|
60 | end
|
---|
61 |
|
---|
62 | it 'instruction_details should be assigned properly' do
|
---|
63 | @action.instruction_details.activity_id.should == 'at0003'
|
---|
64 | end
|
---|
65 | end
|
---|