source: ruby/branches/0.5/spec/lib/open_ehr/assumed_library_types/time_definitions_spec.rb @ 284

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

TimeDefinition? completed

File size: 3.2 KB
Line 
1require File.dirname(__FILE__) + '/../../../spec_helper'
2include OpenEHR::AssumedLibraryTypes
3
4describe TimeDefinitions do
5  describe 'year behavior' do
6    it 'should more than zero in openEHR specification' do
7      TimeDefinitions.should be_valid_year 0
8    end
9
10    it '-1 should not be valid year' do
11      TimeDefinitions.should_not be_valid_year -1
12    end
13
14    it 'nil year should be invaild' do
15      TimeDefinitions.should_not be_valid_year nil
16    end
17  end
18
19
20  describe 'month behavior' do
21    (1..12).each do |month|
22      it "should valid #{month}" do
23        TimeDefinitions.should be_valid_month month
24      end
25    end
26   
27    it '0th month should be invalid' do
28      TimeDefinitions.should_not be_valid_month 0
29    end
30   
31    it '13th month should be invalid' do
32      TimeDefinitions.should_not be_valid_month 13
33    end
34  end
35
36  describe 'day behavior' do
37    it '0 day should not be valid day' do
38      TimeDefinitions.should_not be_valid_day(1,2,0)
39    end
40
41    it '32 day should not be valid day' do
42      TimeDefinitions.should_not be_valid_day(1,2,32)
43    end
44
45    it 'should be valid 2009-09-19' do
46      TimeDefinitions.should be_valid_day(2009,9,19)
47    end
48
49    it 'should be invalid 2009 nil 19' do
50      TimeDefinitions.should_not be_valid_day(2009, nil,19)
51    end
52
53    it 'should be invalid nil 09 19' do
54      TimeDefinitions.should_not be_valid_day(nil, 9, 19)
55    end
56
57    it 'should be valid 2009 09' do
58      TimeDefinitions.should be_valid_day(2009,9,nil)
59    end
60  end
61
62  describe 'hour behavior' do
63    it 'should be valid hour 0,0,0' do
64      TimeDefinitions.should be_valid_hour(0,0,0)
65    end
66
67    it 'should be valid hour 12,59,59' do
68      TimeDefinitions.should be_valid_hour(12,59,59)
69    end
70
71    it 'should not be valid hour 12,60,59' do
72      TimeDefinitions.should_not be_valid_hour(12,60,59)
73    end
74
75    it 'should not be valid hour 12,59,60' do
76      TimeDefinitions.should_not be_valid_hour(12,59,60)
77    end
78
79    it 'should be valid hour 24,0,0' do
80      TimeDefinitions.should be_valid_hour(24,0,0)
81    end
82
83    it 'should not be valid hour 24,0,1' do
84      TimeDefinitions.should_not be_valid_hour(24,0,1)
85    end
86
87
88    it 'should be vaild hour 12,1' do
89      TimeDefinitions.should be_valid_hour(12,1)
90    end
91
92    it 'should not be valid hour 12,nil,1' do
93      TimeDefinitions.should be_valid_hour(12,nil,1)
94    end
95
96    it 'should be valid hour 12' do
97      TimeDefinitions.should be_valid_hour(12)
98    end
99  end
100
101  describe 'minute limit' do
102    it 'should be more than 0' do
103      TimeDefinitions.should be_valid_minute 0
104    end
105
106    it 'should be not less than 0' do
107      TimeDefinitions.should_not be_valid_minute -1
108    end
109
110    it 'should less than 60' do
111      TimeDefinitions.should be_valid_minute 59
112    end
113
114    it 'should not valid minute 60' do
115      TimeDefinitions.should_not be_valid_minute 60
116    end
117  end
118
119  describe 'second limit' do
120    it 'should be more than 0' do
121      TimeDefinitions.should be_valid_second 0
122    end
123
124    it 'should be not less than 0' do
125      TimeDefinitions.should_not be_valid_second -1
126    end
127
128    it 'should less than 60' do
129      TimeDefinitions.should be_valid_second 59
130    end
131
132    it 'should not valid minute 60' do
133      TimeDefinitions.should_not be_valid_second 60
134    end
135  end
136end
Note: See TracBrowser for help on using the repository browser.