summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorEvan Read <eread@gitlab.com>2019-08-19 06:33:14 +0000
committerEvan Read <eread@gitlab.com>2019-08-19 06:33:14 +0000
commitfd3d2a6811ea4c512d3a38f11407b7f9adf65bf0 (patch)
treeece5baa8f4167ad2f8d3953d4db196fdfae3d9e4 /doc
parente40abf9757683c222f724d0f10fbc03475b1b51d (diff)
parentc2c86e35149b20b4dc3af083cc16ac42d50b3e58 (diff)
downloadgitlab-ce-fd3d2a6811ea4c512d3a38f11407b7f9adf65bf0.tar.gz
Merge branch 'doc-be_like_time' into 'master'
Add `be_like_time` matcher to Testing Styleguide See merge request gitlab-org/gitlab-ce!31833
Diffstat (limited to 'doc')
-rw-r--r--doc/development/testing_guide/best_practices.md13
1 files changed, 13 insertions, 0 deletions
diff --git a/doc/development/testing_guide/best_practices.md b/doc/development/testing_guide/best_practices.md
index a1f7d1d7253..f30a83a4c71 100644
--- a/doc/development/testing_guide/best_practices.md
+++ b/doc/development/testing_guide/best_practices.md
@@ -445,6 +445,19 @@ complexity of RSpec expectations.They should be placed under
a certain type of specs only (e.g. features, requests etc.) but shouldn't be if
they apply to multiple type of specs.
+#### `be_like_time`
+
+Time returned from a database can differ in precision from time objects
+in Ruby, so we need flexible tolerances when comparing in specs. We can
+use `be_like_time` to compare that times are within one second of each
+other.
+
+Example:
+
+```ruby
+expect(metrics.merged_at).to be_like_time(time)
+```
+
#### `have_gitlab_http_status`
Prefer `have_gitlab_http_status` over `have_http_status` because the former