source: ruby/branches/0.5/spec/lib/open_ehr/assumed_library_types/iso8601_date_time_spec.rb@ 287

Last change on this file since 287 was 287, checked in by KOBAYASHI, Shinji, 15 years ago

iso8601 date time completed

File size: 1.3 KB
Line 
1require File.dirname(__FILE__) + '/../../../spec_helper'
2include OpenEHR::AssumedLibraryTypes
3
4describe ISO8601DateTime do
5 before(:each) do
6 @iso8601date_time = ISO8601DateTime.new('2009-06-29T12:34:56.78+0900')
7 end
8
9 it 'should be an instance of ISO8601DateTime' do
10 @iso8601date_time.should be_an_instance_of ISO8601DateTime
11 end
12
13 it 'should be 2009-06-29T12:34:56.78T+09:00 as string' do
14 @iso8601date_time.as_string.should == '2009-06-29T12:34:56.78+0900'
15 end
16
17 it 'should raise ArgumentError with invalid date format' do
18 lambda {
19 ISO8601DateTime.new('2009:06:29Z12-34-56')
20 }.should raise_error ArgumentError
21 end
22
23 it 'should raise ArgumentErrow with empty argument' do
24 lambda {
25 ISO8601DateTime.new('')
26 }.should raise_error ArgumentError
27 end
28
29 it 'allows without fractional second' do
30 lambda {
31 ISO8601DateTime.new('2009-06-29T12:34:56')
32 }.should_not raise_error ArgumentError
33 end
34
35 describe 'partial date' do
36 it 'should recognize 2009-06' do
37 @iso8601date_time.day = nil
38 @iso8601date_time.as_string.should == '2009-06'
39 end
40
41 it 'should recognize 2009' do
42 @iso8601date_time.day = nil
43 @iso8601date_time.month = nil
44 @iso8601date_time.as_string.should == '2009'
45 end
46 end
47end
Note: See TracBrowser for help on using the repository browser.