Sha256: a2f0622f1fcb0246fd5ba7df597bd1be936b8ec040271b27491a356d9fce1a1c
Contents?: true
Size: 858 Bytes
Versions: 2
Compression:
Stored size: 858 Bytes
Contents
require 'active_model' require 'age_calculator/validator' # Set timezone require 'active_support/time' # For testing Date and TimeWithZone objects Time.zone = 'Hawaii' # Enable travel_to require 'active_support/testing/time_helpers' include ActiveSupport::Testing::TimeHelpers # Locale I18n.enforce_available_locales = true I18n.load_path += AgeValidator.locales class Adult include ActiveModel::Validations attr_accessor :birthday validates :birthday, age: { over: 18 } def age(asof: nil) AgeCalculator.new(birthday).age(asof: asof) end end class AdultAllowBlank include ActiveModel::Validations attr_accessor :birthday validates :birthday, age: { over: 18 }, allow_blank: true end class AdultAsOf include ActiveModel::Validations attr_accessor :birthday validates :birthday, age: { over: 18, asof: Date.new(2018,1,2) } end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
age_calculator-2.0.0 | test/load_models.rb |
age_calculator-1.2.1 | test/load_models.rb |