File tree 1 file changed +19
-0
lines changed
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,25 @@ so we need to set some guidelines for their use going forward:
95
95
96
96
[ lets-not ] : https://robots.thoughtbot.com/lets-not
97
97
98
+ ### Time-sensitive tests
99
+
100
+ [ Timecop] ( https://github.com/travisjeffery/timecop ) is available in our
101
+ Ruby-based tests for verifying things that are time-sensitive. Any test that
102
+ exercises or verifies something time-sensitive should make use of Timecop to
103
+ prevent transient test failures.
104
+
105
+ Example:
106
+
107
+ ``` ruby
108
+ it ' is overdue' do
109
+ issue = build(:issue , due_date: Date .tomorrow)
110
+
111
+ Timecop .freeze(3 .days.from_now) do
112
+ expect(issue).to be_overdue
113
+ end
114
+ end
115
+ ```
116
+
98
117
### Test speed
99
118
100
119
GitLab has a massive test suite that, without parallelization, can take more
You can’t perform that action at this time.
0 commit comments