[374] | 1 | require File.dirname(__FILE__) + '/../../../../../spec_helper'
|
---|
| 2 | include OpenEHR::AM::Archetype::ConstraintModel
|
---|
| 3 |
|
---|
| 4 | describe ArchetypeConstraint do
|
---|
| 5 | before(:each) do
|
---|
| 6 | parent = stub(ArchetypeConstraint, :path => '/data/[at0001]')
|
---|
| 7 | @archetype_constraint =
|
---|
| 8 | ArchetypeConstraint.new(:path => '/data/events[at0003]/data/items[at0025]/value/magnitude',
|
---|
| 9 | :parent => parent)
|
---|
| 10 | end
|
---|
| 11 |
|
---|
| 12 | it 'should be an instance of ArchetypeConstraint' do
|
---|
| 13 | @archetype_constraint.should be_an_instance_of ArchetypeConstraint
|
---|
| 14 | end
|
---|
| 15 |
|
---|
| 16 | it 'path should be assigned properly' do
|
---|
| 17 | @archetype_constraint.path.should == '/data/events[at0003]/data/items[at0025]/value/magnitude'
|
---|
| 18 | end
|
---|
| 19 |
|
---|
| 20 | it 'should raise ArgumentError when path is not assigned' do
|
---|
| 21 | lambda {
|
---|
| 22 | @archetype_constraint.path = nil
|
---|
| 23 | }.should raise_error ArgumentError
|
---|
| 24 | end
|
---|
| 25 |
|
---|
| 26 | it 'has_path? should return true if it has path' do
|
---|
| 27 | @archetype_constraint.should have_path 'events[at0003]'
|
---|
| 28 | end
|
---|
| 29 |
|
---|
| 30 | it 'has_path? should return false if ti does not have path' do
|
---|
| 31 | @archetype_constraint.should_not have_path 'events[at0004]'
|
---|
| 32 | end
|
---|
| 33 |
|
---|
| 34 | it 'parent should assigned properly' do
|
---|
| 35 | @archetype_constraint.parent.path.should == '/data/[at0001]'
|
---|
| 36 | end
|
---|
| 37 |
|
---|
| 38 | it 'is congruent means this node starts from parent node' do
|
---|
| 39 | @archetype_constraint.should_not be_congruent
|
---|
| 40 | end
|
---|
| 41 |
|
---|
| 42 | it 'is congruent when path starts with parent path' do
|
---|
| 43 | @archetype_constraint.path = '/data/[at0001]/test'
|
---|
| 44 | @archetype_constraint.should be_congruent
|
---|
| 45 | end
|
---|
| 46 |
|
---|
| 47 | it 'node_conforms_to return true if path is follower' do
|
---|
| 48 | other = stub(ArchetypeConstraint, :path => '/data/events[at0003]')
|
---|
| 49 | @archetype_constraint.node_conforms_to?(other).should be_true
|
---|
| 50 | end
|
---|
| 51 |
|
---|
| 52 | it 'node_conforms_to return false if path is other lineage' do
|
---|
| 53 | other = stub(ArchetypeConstraint, :path => '/event/')
|
---|
| 54 | @archetype_constraint.node_conforms_to?(other).should be_false
|
---|
| 55 | end
|
---|
| 56 | end
|
---|