Sha256: 5502f17d4a6ef68344cfcdb1e55d517bc3b466ab9ccd4fea661e3eebda4b51d7

Contents?: true

Size: 784 Bytes

Versions: 8

Compression:

Stored size: 784 Bytes

Contents

require "helper"

class DateValidationsTest < Test::Unit::TestCase
  describe "date validation with a normal string column" do
    class Person < Ohm::Model
      include Ohm::DateValidations

      attribute :birthday
      
      def validate
        assert_date :birthday
      end
    end

    test "accepts all canonical dates" do
      assert Person.new(:birthday => "2010-05-05").valid?
      assert Person.new(:birthday => "2010-5-5").valid?
      assert Person.new(:birthday => "2010-05-5").valid?
      assert Person.new(:birthday => "2010-5-05").valid?
    end

    test "also catches invalid dates" do
      assert ! Person.new(:birthday => "2010-02-29").valid?
    end

    test "invalid when empty" do
      assert ! Person.new(:birthday => "").valid?
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ohm-contrib-0.0.31 test/test_ohm_date_validations.rb
ohm-contrib-0.0.30 test/test_ohm_date_validations.rb
ohm-contrib-0.0.29 test/test_ohm_date_validations.rb
ohm-contrib-0.0.28 test/test_ohm_date_validations.rb
ohm-contrib-0.0.27 test/test_ohm_date_validations.rb
ohm-contrib-0.0.26 test/test_ohm_date_validations.rb
ohm-contrib-0.0.25 test/test_ohm_date_validations.rb
ohm-contrib-0.0.24 test/test_ohm_date_validations.rb