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::Text
|
---|
5 | include OpenEHR::RM::DataTypes::Quantity::DateTime
|
---|
6 | include OpenEHR::RM::DataTypes::Encapsulated
|
---|
7 |
|
---|
8 | describe Instruction do
|
---|
9 | it_should_behave_like 'entry'
|
---|
10 |
|
---|
11 | before(:each) do
|
---|
12 | narrative = DvText.new(:value => 'instruction test')
|
---|
13 | activities = stub(Array, :size => 5, :empty? => false)
|
---|
14 | expiry_time = DvDateTime.new(:value => '2009-11-18T20:58:34')
|
---|
15 | wf_definition = stub(DvParsable, :value => 'behavior driven')
|
---|
16 | @instruction= Instruction.new(:archetype_node_id => 'at0001',
|
---|
17 | :name => @name,
|
---|
18 | :language => @language,
|
---|
19 | :encoding => @encoding,
|
---|
20 | :subject => @subject,
|
---|
21 | :narrative => narrative,
|
---|
22 | :activities => activities,
|
---|
23 | :expiry_time => expiry_time,
|
---|
24 | :wf_definition => wf_definition)
|
---|
25 | end
|
---|
26 |
|
---|
27 | it 'should be an instance of Instruction' do
|
---|
28 | @instruction.should be_an_instance_of Instruction
|
---|
29 | end
|
---|
30 |
|
---|
31 | it 'narrative should be assigned properly' do
|
---|
32 | @instruction.narrative.value.should == 'instruction test'
|
---|
33 | end
|
---|
34 |
|
---|
35 | it 'should raise ArgumentError when narrative is assined with nil' do
|
---|
36 | lambda {
|
---|
37 | @instruction.narrative = nil
|
---|
38 | }.should raise_error ArgumentError
|
---|
39 | end
|
---|
40 |
|
---|
41 | it 'activities should be assigned properly' do
|
---|
42 | @instruction.activities.size.should be_equal 5
|
---|
43 | end
|
---|
44 |
|
---|
45 | it 'should raise ArgumentError with empty activities' do
|
---|
46 | lambda {
|
---|
47 | @instruction.activities = [ ]
|
---|
48 | }.should raise_error ArgumentError
|
---|
49 | end
|
---|
50 |
|
---|
51 | it 'expiry_time should be assigned properly' do
|
---|
52 | @instruction.expiry_time.value.should == '2009-11-18T20:58:34'
|
---|
53 | end
|
---|
54 |
|
---|
55 | it 'wf_definition should be assigned properly' do
|
---|
56 | @instruction.wf_definition.value.should == 'behavior driven'
|
---|
57 | end
|
---|
58 | end
|
---|