source: ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/c_attribute_spec.rb@ 375

Last change on this file since 375 was 375, checked in by KOBAYASHI, Shinji, 14 years ago

refs #74

File size: 1.7 KB
Line 
1require File.dirname(__FILE__) + '/../../../../../spec_helper'
2include OpenEHR::AM::Archetype::ConstraintModel
3include OpenEHR::AssumedLibraryTypes
4
5describe 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
56end
57
58
59
Note: See TracBrowser for help on using the repository browser.