Sha256: 7f56f925b6af849c2b61f51c452b6f8528a89b0b95caafe63d8a768652afe922
Contents?: true
Size: 999 Bytes
Versions: 7
Compression:
Stored size: 999 Bytes
Contents
module Rspectacular module ActiveRecord module Matchers class DatelinessMatcher include Shoulda::ActiveRecord::Helpers def initialize(date_field) @date_field = date_field.to_s @date_method = "#{date_field.to_s}=".to_sym end def matches?(dateable) @dateable = dateable dateable.send(@date_method, Date.today) dateable.valid? !dateable.errors[@date_field].include?("is not a valid date") end def failure_message "Expected #{@date_field} to contain a valid date, got: #{pretty_error_messages(@dateable)}" end def negative_failure_message "Expected #{@date_field} to contain an invalid date, got: #{pretty_error_messages(@dateable)}" end def description "should be contain a valid date" end end def validate_dateliness_of(date) DatelinessMatcher.new(date) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems