Sha256: f9fdc2df5cd9fc0f33ef8961384ee6d6fe272e2124d3d2a9d7e9e2be496dd73b

Contents?: true

Size: 1.42 KB

Versions: 6

Compression:

Stored size: 1.42 KB

Contents

require File.dirname(__FILE__) + '/../../../spec_helper'
include OpenEHR::AssumedLibraryTypes

describe ISO8601DateTime do
  before(:each) do
    @iso8601date_time = ISO8601DateTime.new('2009-06-29T12:34:56.78+0900')
  end

  it 'should be an instance of ISO8601DateTime' do
    @iso8601date_time.should be_an_instance_of ISO8601DateTime
  end

  it 'should be 2009-06-29T12:34:56.78T+09:00 as string' do
    @iso8601date_time.as_string.should == '2009-06-29T12:34:56.78+0900'
  end

  it 'should raise ArgumentError with invalid date format' do
    lambda {
      ISO8601DateTime.new('2009:06:29Z12-34-56')
    }.should raise_error ArgumentError
  end

  it 'should raise ArgumentErrow with empty argument' do
    lambda {
      ISO8601DateTime.new('')
    }.should raise_error ArgumentError
  end    

  it 'allows without fractional second' do
    lambda {
      ISO8601DateTime.new('2009-06-29T12:34:56')
    }.should_not raise_error ArgumentError
  end

  it 'should be comparable' do
    ISO8601DateTime.new('2009-06-29T12:34:56.78+0900').should > ISO8601DateTime.new('2009-06-29T12:34:56.77+0900')
  end

  describe 'partial date' do
    it 'should recognize 2009-06' do
      @iso8601date_time.day = nil      
      @iso8601date_time.as_string.should == '2009-06'
    end

    it 'should recognize 2009' do
      @iso8601date_time.day = nil
      @iso8601date_time.month = nil
      @iso8601date_time.as_string.should == '2009'
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
openehr-1.2.8 spec/lib/openehr/assumed_library_types/iso8601_date_time_spec.rb
openehr-1.2.7 spec/lib/openehr/assumed_library_types/iso8601_date_time_spec.rb
openehr-1.2.6 spec/lib/openehr/assumed_library_types/iso8601_date_time_spec.rb
openehr-1.2.5 spec/lib/openehr/assumed_library_types/iso8601_date_time_spec.rb
openehr-1.2.4 spec/lib/openehr/assumed_library_types/iso8601_date_time_spec.rb
openehr-1.2.3 spec/lib/openehr/assumed_library_types/iso8601_date_time_spec.rb