Sha256: 0bacf467434b0f2a8d7956f2821cc25b2f4b4751da2249ffa728a81b6e20ecc5

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

describe DateTime do

  let(:date) { DateTime.new }

  describe 'class methods' do
    it 'responds to edtf' do
      DateTime.respond_to?(:edtf).should == true
    end
  end
  
  describe 'instance methods' do
    [:uncertain?, :approximate?, :unspecified?, :uncertain, :approximate, :unspecified].each do |method|
      it "responds to #{method}" do
        DateTime.new.respond_to?(method).should == true
      end
    end
  end
  
  describe '#uncertain?' do
    
    it { should_not be_uncertain }

    [:year, :month, :day].each do |part|
      it "should not be uncertain by default (#{part})" do
        DateTime.new.uncertain?(part).should == false
      end

      it "should be uncertain if set to uncertain (#{part})" do
        date.uncertain.send("#{part}=", true)
        date.uncertain?(part).should == true
      end

      ([:year, :month, :day] - [part]).each do |other|
        it "#{other} should not be uncertain if #{part} is uncertain" do
          date.uncertain.send("#{part}=", true)
          date.uncertain?(other).should == false
        end
      end
      
    end
    
  end
    
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
edtf-0.0.2 spec/edtf/extensions_spec.rb
edtf-0.0.1 spec/edtf/extensions_spec.rb