gitlab-org--gitlab-foss/spec/support/matchers/be_like_time.rb
Nick Thomas bfb20200e9 Add a be_like_time matcher and use it in specs
The amount of precision times have in databases is variable, so we need
tolerances when comparing in specs. It's better to have the tolerance defined
in one place than several.
2016-10-17 14:44:20 +01:00

13 lines
300 B
Ruby

RSpec::Matchers.define :be_like_time do |expected|
match do |actual|
expect(actual).to be_within(1.second).of(expected)
end
description do
"within one second of #{expected}"
end
failure_message do |actual|
"expected #{actual} to be within one second of #{expected}"
end
end