[394] | 1 | require File.dirname(__FILE__) + '/../../../../../../spec_helper'
|
---|
| 2 | include OpenEHR::AM::Archetype::ConstraintModel::Primitive
|
---|
| 3 | include OpenEHR::RM::DataTypes::Text
|
---|
| 4 |
|
---|
| 5 | describe 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 |
|
---|
[397] | 25 | it 'pattern should be assigned properly by constructor' do
|
---|
[394] | 26 | @c_string.pattern.should == 't[a-z]st'
|
---|
| 27 | end
|
---|
| 28 |
|
---|
[397] | 29 | it 'pattern should be assigned properly by method' do
|
---|
| 30 | @c_string.pattern = '.*'
|
---|
| 31 | @c_string.pattern.should == '.*'
|
---|
| 32 | end
|
---|
| 33 |
|
---|
[394] | 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 |
|
---|
[397] | 54 | it 'list should be assigned properly by constructor' do
|
---|
[394] | 55 | @c_string.list.should == ['test', 'behavior']
|
---|
| 56 | end
|
---|
| 57 |
|
---|
[397] | 58 | it 'list shoudl be assigned properly by method' do
|
---|
| 59 | @c_string.list = ['spec']
|
---|
| 60 | @c_string.list.should == ['spec']
|
---|
| 61 | end
|
---|
| 62 |
|
---|
[394] | 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
|
---|
| 69 | end
|
---|