source: ruby/branches/0.5/spec/lib/open_ehr/rm/data_types/quantity/dv_ordinal_spec.rb @ 248

Last change on this file since 248 was 248, checked in by KOBAYASHI, Shinji, 11 years ago

move DvAmount?, DvCount? test to spec

File size: 2.6 KB
Line 
1require File.dirname(__FILE__) + '/../../../../../spec_helper'
2include OpenEHR::RM::DataTypes::Quantity
3include OpenEHR::RM::DataTypes::Text
4include OpenEHR::RM::Support::Identification
5
6describe DvOrdinal do
7  before(:each) do
8    terminology_id = stub(TerminologyId, :value => 'urine:prot')
9    code_phrase = stub(CodePhrase, :terminology_id => terminology_id)
10    symbol = stub(DvCodedText, :code_string => '+',
11                  :defining_code => code_phrase)
12    dv_text = stub(DvText, :value => 'limits')
13    limits = stub(ReferenceRange, :meaning => dv_text)
14    @dv_ordinal = DvOrdinal.new(:value => 1,
15                                :symbol => symbol,
16                                :limits => limits)
17  end
18
19  it 'should be an instance of DvOrdinal' do
20    @dv_ordinal.should be_an_instance_of DvOrdinal
21  end
22
23  it 's value should be equal 1' do
24    @dv_ordinal.value.should be_equal 1
25  end
26
27  it 's symbol should be + code string' do
28    @dv_ordinal.symbol.code_string.should == '+'
29  end
30
31  it 's symbol defining_code should be urine:prot' do
32    @dv_ordinal.symbol.defining_code.terminology_id.value.should ==
33      'urine:prot'
34  end
35
36  it 'should be strictry comperable to other DvOrdinal' do
37    terminology_id = stub(TerminologyId, :value => 'urine:prot')
38    code_phrase = stub(CodePhrase, :terminology_id => terminology_id)
39    symbol = stub(DvCodedText, :defining_code => code_phrase)
40    dv_ordinal = DvOrdinal.new(:value => 2,
41                               :symbol => symbol)
42    @dv_ordinal.is_strictly_comparable_to?(dv_ordinal).should be_true
43  end
44
45  it 's limit.value should be limits' do
46    @dv_ordinal.limits.meaning.value.should == 'limits'
47  end
48
49  it 'should raise error when limits.value is not limitted' do
50    unlimit = stub(DvText, :value => 'unimitted')
51    unlimitted_range = stub(ReferenceRange, :meaning => unlimit)
52    lambda {
53      @dv_ordinal.limits = unlimitted_range
54    }.should raise_error ArgumentError
55  end
56
57  it 'should be comparable' do
58    dv_ordinal = stub(DvOrdinal, :value => 2)
59    @dv_ordinal.should < dv_ordinal
60  end
61
62  it 'is_strictly comparable should be false with other instance' do
63    @dv_ordinal.is_strictly_comparable_to?('dummy').should be_false
64  end
65
66  it 'is strictly comparable should be false with other terminology' do
67    terminology_id = stub(Terminology, :value => 'blood pressure')
68    code_phrase = stub(CodePhrase, :terminology_id => terminology_id)
69    symbol = stub(DvCodedText, :defining_code => code_phrase)
70    dv_ordinal = DvOrdinal.new(:value => 3,
71                               :symbol => symbol)
72    @dv_ordinal.is_strictly_comparable_to?(dv_ordinal).should be_false
73  end
74end
Note: See TracBrowser for help on using the repository browser.