1 | require File.dirname(__FILE__) + '/../../../../../spec_helper'
|
---|
2 | include OpenEHR::AM::Archetype::ConstraintModel
|
---|
3 | include OpenEHR::AssumedLibraryTypes
|
---|
4 |
|
---|
5 | describe CAttribute do
|
---|
6 | before(:each) do
|
---|
7 | existence = Interval.new(:lower => 0, :upper => 1)
|
---|
8 | children = stub(CObject, :rm_type_name => 'DV_AMOUNT')
|
---|
9 | @c_attribute = CAttribute.new(:path => '/event/[at0001]/',
|
---|
10 | :rm_attribute_name => 'DV_TEXT',
|
---|
11 | :existence => existence,
|
---|
12 | :children => children)
|
---|
13 | end
|
---|
14 |
|
---|
15 | it 'should be an instance of CAttribute' do
|
---|
16 | @c_attribute.should be_an_instance_of CAttribute
|
---|
17 | end
|
---|
18 |
|
---|
19 | it 'rm_attribute_name should be assigned properly' do
|
---|
20 | @c_attribute.rm_attribute_name.should == 'DV_TEXT'
|
---|
21 | end
|
---|
22 |
|
---|
23 | it 'should raise ArguemntError rm_attribute_name is empty' do
|
---|
24 | lambda {
|
---|
25 | @c_attribute.rm_attribute_name = ''
|
---|
26 | }.should raise_error ArgumentError
|
---|
27 | end
|
---|
28 |
|
---|
29 | it 'should raise ArgumentError rm_attribute_name is nil' do
|
---|
30 | lambda {
|
---|
31 | @c_attribute.rm_attribute_name = nil
|
---|
32 | }.should raise_error ArgumentError
|
---|
33 | end
|
---|
34 |
|
---|
35 | it 'existence should be assigned properly' do
|
---|
36 | @c_attribute.existence.lower.should be_equal 0
|
---|
37 | end
|
---|
38 |
|
---|
39 | it 'existence.lower should be more than 0' do
|
---|
40 | invalid_existence = Interval.new(:lower => -1, :upper => 1)
|
---|
41 | lambda {
|
---|
42 | @c_attribute.existence = invalid_existence
|
---|
43 | }.should raise_error ArgumentError
|
---|
44 | end
|
---|
45 |
|
---|
46 | it 'existence.upper should be equal or less than 1' do
|
---|
47 | invalid_existence = Interval.new(:lower => 0, :upper => 2)
|
---|
48 | lambda {
|
---|
49 | @c_attribute.existence = invalid_existence
|
---|
50 | }.should raise_error ArgumentError
|
---|
51 | end
|
---|
52 |
|
---|
53 | it 'children should be assigned properly' do
|
---|
54 | @c_attribute.children.rm_type_name.should == 'DV_AMOUNT'
|
---|
55 | end
|
---|
56 | end
|
---|
57 |
|
---|
58 |
|
---|
59 |
|
---|