Skip to content

Commit 3e6a5cf

Browse files
committed
Merge branch 'rs-document-timecop' into 'master'
Document Timecop usage for time-sensitive tests See merge request !9383
2 parents c63016a + ec32625 commit 3e6a5cf

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

doc/development/testing.md

+19
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,25 @@ so we need to set some guidelines for their use going forward:
9595

9696
[lets-not]: https://robots.thoughtbot.com/lets-not
9797

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+
98117
### Test speed
99118

100119
GitLab has a massive test suite that, without parallelization, can take more

0 commit comments

Comments
 (0)