Ignore:
Timestamp:
Sep 14, 2009, 1:21:16 PM (15 years ago)
Author:
KOBAYASHI, Shinji
Message:

support/identification package moving from test/unit to rspec

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ruby/branches/0.5/spec/lib/open_ehr/assumed_library_types/iso_8601_date_spec.rb

    r256 r259  
    2525  it 'should be 2009-09-10 as_string' do
    2626    @iso8601date.as_string.should == '2009-09-10'
     27  end
     28
     29  it 'should be extended ' do
     30    @iso8601date.is_extended?.should be_true
    2731  end
    2832
     
    6569  end
    6670
    67   describe 'January behavior' do
    68     before do
    69       @iso8601date.month = 1
    70     end
     71  [1,3,5,7,8,10,12].each do |m|
     72    describe '#{m}th month behavior' do
     73      before do
     74        @iso8601date.month = m
     75      end
     76     
     77      it 'should have 31 days' do
     78        lambda{
     79          @iso8601date.day = 31
     80        }.should_not raise_error ArgumentError
     81      end
    7182
    72     it 'January should have 31 days' do
    73       lambda{@iso8601date.day = 31}.should_not raise_error ArgumentError
    74     end
    75 
    76     it 'January should not have 32 days' do
    77       lambda{@iso8601date.month = 32}.should raise_error ArgumentError
     83      it 'should not have 32 days' do
     84        lambda{
     85          @iso8601date.day = 32
     86        }.should raise_error ArgumentError
     87      end
    7888    end
    7989  end
     
    127137  end
    128138
    129   describe 'March behavior' do
    130     before do
    131       @iso8601date.month = 3
    132     end
     139  [4,6,9,11].each do |month|
     140    describe "#{month}th month behavior" do
     141      before do
     142        @iso8601date.month = month
     143      end
    133144
    134     it '31 day should not raise ArgumentError' do
    135       lambda{@iso8601date.day = 31}.should_not raise_error ArgumentError
    136     end
     145      it '30 day should not raise ArgumentError' do
     146        lambda{
     147          @iso8601date.day = 30
     148        }.should_not raise_error ArgumentError
     149      end
    137150
    138     it '32 day should raise ArgumentError' do
    139       lambda{@iso8601date.day = 32}.should raise_error ArgumentError
     151      it '31 day should raise ArgumentError' do
     152        lambda{
     153          @iso8601date.day = 31
     154        }.should raise_error ArgumentError
     155      end
    140156    end
    141157  end
    142158
    143   describe 'April behavior' do
    144     before do
    145       @iso8601date.month = 4
     159  describe 'partial date data' do
     160    describe 'day unknown' do
     161      before do
     162        @iso8601date.day = nil
     163      end
     164     
     165      it 'day should be unknown' do
     166        @iso8601date.should be_day_unknown
     167      end
     168     
     169      it 'should be 2009-09 as string' do
     170        @iso8601date.as_string.should == '2009-09'
     171      end
     172     
     173      it 'should be partial' do
     174        @iso8601date.is_partial?.should be_true
     175      end
     176     
     177      after do
     178        @iso8601date.day = 10
     179      end
    146180    end
    147 
    148     it '30 day should not raise ArgumentError' do
    149       lambda{@iso8601date.day = 30}.should_not raise_error ArgumentError
    150     end
    151 
    152     it '31 day should raise ArgumentError' do
    153       lambda{@iso8601date.day = 31}.should raise_error ArgumentError
     181   
     182    describe 'month unknown' do
     183      before do
     184        @iso8601date.day = nil
     185        @iso8601date.month = nil
     186      end
     187     
     188      it 'should raise ArgumentError with nil month and not nil day' do
     189        lambda {
     190          @iso8601date.day = 11
     191        }.should raise_error ArgumentError
     192      end
    154193    end
    155194  end
     195
    156196end
Note: See TracChangeset for help on using the changeset viewer.