Blob Blame History Raw
From a1431b9859e8b8bc6810cf98687ab4c382d0adcf Mon Sep 17 00:00:00 2001
From: Josh Nichols <joshua.nichols@gmail.com>
Date: Mon, 31 Jan 2022 20:56:53 +0000
Subject: [PATCH] Use a hard-coded DateTime instead of DateTime.now. This
 avoids some differences in Rails 7.0, where it can return nanoseconds,
 leading things to be not quiete equal

---
 .../active_model/validate_inclusion_of_matcher_spec.rb      | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb b/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb
index 80599530c..dd9b7933c 100644
--- a/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb
+++ b/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb
@@ -145,7 +145,7 @@ def validation_matcher_scenario_args
     end
 
     context 'against a datetime attribute' do
-      now = DateTime.now
+      now = DateTime.new(2022, 01, 01)
 
       define_method(:now) { now }
 
@@ -448,6 +448,7 @@ def configure_validation_matcher(matcher)
     end
 
     it 'matches given the same array of valid values' do
+      new_now = DateTime.now
       builder = build_object_allowing(possible_values)
       expect_to_match_on_values(builder, possible_values)
     end
@@ -785,8 +786,7 @@ def configure_validation_matcher(matcher)
     include_context 'for a generic attribute'
 
     context 'against a timestamp column' do
-      now = DateTime.now
-
+      now = DateTime.new(2022, 01, 01)
       define_method(:now) { now }
 
       it_behaves_like 'it supports in_array',