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

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

refs #71

File size: 2.0 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 by constructor' do
26 @c_string.pattern.should == 't[a-z]st'
27 end
28
29 it 'pattern should be assigned properly by method' do
30 @c_string.pattern = '.*'
31 @c_string.pattern.should == '.*'
32 end
33
34 it 'should raise ArgumentError if either list or pattern is not nil' do
35 lambda {
36 @c_string.list = ['test','driven']
37 }.should raise_error ArgumentError
38 end
39
40 it 'should raise ArgumentError if both list and pattern are nil' do
41 lambda {
42 @c_string.pattern = nil
43 }.should raise_error ArgumentError
44 end
45
46 describe 'list attribute' do
47 before(:each) do
48 @default_value = DvText.new(:value => 'default')
49 @c_string = CString.new(:default_value => @default_value,
50 :assumed_value => 'assumed',
51 :list => ['test', 'behavior'])
52 end
53
54 it 'list should be assigned properly by constructor' do
55 @c_string.list.should == ['test', 'behavior']
56 end
57
58 it 'list shoudl be assigned properly by method' do
59 @c_string.list = ['spec']
60 @c_string.list.should == ['spec']
61 end
62
63 it 'should raise ArgumentError if both pattern and list is not nil' do
64 lambda {
65 @c_string.pattern = 'file.*'
66 }.should raise_error ArgumentError
67 end
68 end
69end
Note: See TracBrowser for help on using the repository browser.