Commit fd3d2a68 authored by Evan Read's avatar Evan Read

Merge branch 'doc-be_like_time' into 'master'

Add `be_like_time` matcher to Testing Styleguide

See merge request gitlab-org/gitlab-ce!31833
parents e40abf97 c2c86e35
...@@ -445,6 +445,19 @@ complexity of RSpec expectations.They should be placed under ...@@ -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 a certain type of specs only (e.g. features, requests etc.) but shouldn't be if
they apply to multiple type of specs. 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` #### `have_gitlab_http_status`
Prefer `have_gitlab_http_status` over `have_http_status` because the former Prefer `have_gitlab_http_status` over `have_http_status` because the former
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment