[382] | 1 | require File.dirname(__FILE__) + '/../../../../../spec_helper'
|
---|
| 2 | include OpenEHR::AM::Archetype::ConstraintModel
|
---|
| 3 | include OpenEHR::AssumedLibraryTypes
|
---|
| 4 |
|
---|
| 5 | describe ArchetypeSlot do
|
---|
| 6 | before(:each) do
|
---|
| 7 | occurrences = Interval.new(:lower => 0, :upper => 1)
|
---|
| 8 | includes = stub(Set, :empty? => false, :size => 2)
|
---|
| 9 | excludes = stub(Set, :empty? => false, :size => 10)
|
---|
| 10 | @archetype_slot = ArchetypeSlot.new(:path => '/event/[at0001]/',
|
---|
| 11 | :rm_type_name => 'DV_TIME',
|
---|
| 12 | :node_id => 'ac0001',
|
---|
| 13 | :occurrences => occurrences,
|
---|
| 14 | :includes => includes,
|
---|
| 15 | :excludes => excludes)
|
---|
| 16 | end
|
---|
| 17 |
|
---|
| 18 | it 'should be an instance of ArchetypeSlot' do
|
---|
| 19 | @archetype_slot.should be_an_instance_of ArchetypeSlot
|
---|
| 20 | end
|
---|
| 21 |
|
---|
| 22 | it 'includes should be assigned properly' do
|
---|
| 23 | @archetype_slot.includes.size.should be_equal 2
|
---|
| 24 | end
|
---|
| 25 |
|
---|
| 26 | it 'should raise ArgumentError when includes are empty' do
|
---|
| 27 | lambda {
|
---|
| 28 | @archetype_slot.includes = Set.new
|
---|
| 29 | }.should raise_error ArgumentError
|
---|
| 30 | end
|
---|
| 31 |
|
---|
| 32 | it 'excludes should be assigned properly' do
|
---|
| 33 | @archetype_slot.excludes.size.should be_equal 10
|
---|
| 34 | end
|
---|
| 35 |
|
---|
| 36 | it 'should raise ArgumentError when excludes are empty' do
|
---|
| 37 | lambda {
|
---|
| 38 | @archetype_slot.excludes = Set.new
|
---|
| 39 | }.should raise_error ArgumentError
|
---|
| 40 | end
|
---|
| 41 |
|
---|
| 42 | it 'any_allowed should be false when includes and excludes are not nil' do
|
---|
| 43 | @archetype_slot.should_not be_any_allowed
|
---|
| 44 | end
|
---|
| 45 |
|
---|
| 46 | it 'any_allowed should be false when includes are nil and excludes are not nil' do
|
---|
| 47 | @archetype_slot.includes = nil
|
---|
| 48 | @archetype_slot.should_not be_any_allowed
|
---|
| 49 | end
|
---|
| 50 |
|
---|
| 51 | it 'any_allowed should be false when includes are not nil and excludes are nil' do
|
---|
| 52 | @archetype_slot.excludes = nil
|
---|
| 53 | @archetype_slot.should_not be_any_allowed
|
---|
| 54 | end
|
---|
| 55 |
|
---|
| 56 | it 'any_allowed should be true when includes and excludes are nil' do
|
---|
| 57 | @archetype_slot.includes = nil
|
---|
| 58 | @archetype_slot.excludes = nil
|
---|
| 59 | @archetype_slot.should be_any_allowed
|
---|
| 60 | end
|
---|
| 61 | end
|
---|