source: ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_string_spec.rb@ 394

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

refs #71

File size: 1.7 KB
Line 
1require File.dirname(__FILE__) + '/../../../../../../spec_helper'
2include OpenEHR::AM::Archetype::ConstraintModel::Primitive
3include OpenEHR::RM::DataTypes::Text
4
5describe CString do
6 before(:each) do
7 @default_value = DvText.new(:value => 'default')
8 @c_string = CString.new(:default_value => @default_value,
9 :assumed_value => 'assumed',
10 :pattern => 't[a-z]st')
11 end
12
13 it 'should be an instance of CString' do
14 @c_string.should be_an_instance_of CString
15 end
16
17 it 'default should be assigned properly' do
18 @c_string.default_value.value.should == 'default'
19 end
20
21 it 'assumed_value should be assigned properly' do
22 @c_string.assumed_value.should == 'assumed'
23 end
24
25 it 'pattern should be assigned properly' do
26 @c_string.pattern.should == 't[a-z]st'
27 end
28
29 it 'should raise ArgumentError if either list or pattern is not nil' do
30 lambda {
31 @c_string.list = ['test','driven']
32 }.should raise_error ArgumentError
33 end
34
35 it 'should raise ArgumentError if both list and pattern are nil' do
36 lambda {
37 @c_string.pattern = nil
38 }.should raise_error ArgumentError
39 end
40
41 describe 'list attribute' do
42 before(:each) do
43 @default_value = DvText.new(:value => 'default')
44 @c_string = CString.new(:default_value => @default_value,
45 :assumed_value => 'assumed',
46 :list => ['test', 'behavior'])
47 end
48
49 it 'list should be assigned properly' do
50 @c_string.list.should == ['test', 'behavior']
51 end
52
53 it 'should raise ArgumentError if both pattern and list is not nil' do
54 lambda {
55 @c_string.pattern = 'file.*'
56 }.should raise_error ArgumentError
57 end
58 end
59end
Note: See TracBrowser for help on using the repository browser.