Sha256: 23f40aa0768d00753348ecd1dc91c85c66414b12ae6255169e84ab9f90c88c34

Contents?: true

Size: 1.27 KB

Versions: 20

Compression:

Stored size: 1.27 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

  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

20 entries across 20 versions & 2 rubygems

Version Path
openehr-1.2.2 spec/lib/openehr/assumed_library_types/iso8601_date_time_spec.rb
openehr-1.2.1 spec/lib/openehr/assumed_library_types/iso8601_date_time_spec.rb
openehr-1.2.0 spec/lib/openehr/assumed_library_types/iso8601_date_time_spec.rb
openehr-1.1.6 spec/lib/openehr/assumed_library_types/iso8601_date_time_spec.rb
openehr-1.1.5 spec/lib/openehr/assumed_library_types/iso8601_date_time_spec.rb
openehr-1.1.4 spec/lib/openehr/assumed_library_types/iso8601_date_time_spec.rb
openehr-1.1.3 spec/lib/openehr/assumed_library_types/iso8601_date_time_spec.rb
openehr-1.1.2 spec/lib/openehr/assumed_library_types/iso8601_date_time_spec.rb
openehr-1.1.1 spec/lib/openehr/assumed_library_types/iso8601_date_time_spec.rb
openehr-1.1.0 spec/lib/openehr/assumed_library_types/iso8601_date_time_spec.rb
open_ehr-1.0.2 spec/lib/open_ehr/assumed_library_types/iso8601_date_time_spec.rb
open_ehr-1.0.1 spec/lib/open_ehr/assumed_library_types/iso8601_date_time_spec.rb
open_ehr-1.0.0 spec/lib/open_ehr/assumed_library_types/iso8601_date_time_spec.rb
open_ehr-0.9.5 spec/lib/open_ehr/assumed_library_types/iso8601_date_time_spec.rb
open_ehr-0.9.4 spec/lib/open_ehr/assumed_library_types/iso8601_date_time_spec.rb
open_ehr-0.9.3 spec/lib/open_ehr/assumed_library_types/iso8601_date_time_spec.rb
open_ehr-0.9.2 spec/lib/open_ehr/assumed_library_types/iso8601_date_time_spec.rb
open_ehr-0.9.1 spec/lib/open_ehr/assumed_library_types/iso8601_date_time_spec.rb
open_ehr-0.9.0 spec/lib/open_ehr/assumed_library_types/iso8601_date_time_spec.rb
open_ehr-0.6.1 spec/lib/open_ehr/assumed_library_types/iso8601_date_time_spec.rb