diff options
author | Rémy Coutable <remy@rymai.me> | 2017-02-20 18:39:26 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-02-20 18:39:26 +0000 |
commit | 3e6a5cf0edbc4029104a7b0f6e96f2a3f5d3eae0 (patch) | |
tree | 7808c5d6c9b48aab8c6578e89b28f86364025f46 | |
parent | c63016a379f34807212f8bdf559bf842cf913231 (diff) | |
parent | ec3262549b2e0c86988b3593464c71f176a66128 (diff) | |
download | gitlab-ce-3e6a5cf0edbc4029104a7b0f6e96f2a3f5d3eae0.tar.gz |
Merge branch 'rs-document-timecop' into 'master'
Document Timecop usage for time-sensitive tests
See merge request !9383
-rw-r--r-- | doc/development/testing.md | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/doc/development/testing.md b/doc/development/testing.md index 500cbefcffb..9b545d7f0f1 100644 --- a/doc/development/testing.md +++ b/doc/development/testing.md @@ -95,6 +95,25 @@ so we need to set some guidelines for their use going forward: [lets-not]: https://robots.thoughtbot.com/lets-not +### Time-sensitive tests + +[Timecop](https://github.com/travisjeffery/timecop) is available in our +Ruby-based tests for verifying things that are time-sensitive. Any test that +exercises or verifies something time-sensitive should make use of Timecop to +prevent transient test failures. + +Example: + +```ruby +it 'is overdue' do + issue = build(:issue, due_date: Date.tomorrow) + + Timecop.freeze(3.days.from_now) do + expect(issue).to be_overdue + end +end +``` + ### Test speed GitLab has a massive test suite that, without parallelization, can take more |