summaryrefslogtreecommitdiff
path: root/spec/support/matchers/be_like_time.rb
blob: b449f7a7ffb2350e6dc1397a66314e62c62581b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# frozen_string_literal: true

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