DEV: adds within_one_minute time matcher (#12109)
This commit is contained in:
parent
9d7dc89d79
commit
8f5233a7bf
|
@ -1629,7 +1629,7 @@ describe Topic do
|
|||
|
||||
expect(topic_timer.user).to eq(Discourse.system_user)
|
||||
expect(topic_timer.topic).to eq(topic)
|
||||
expect(topic_timer.execute_at).to be_within_one_second_of(now + 5.hours)
|
||||
expect(topic_timer.execute_at).to be_within_one_minute_of(now + 5.hours)
|
||||
end
|
||||
|
||||
describe 'when topic is already closed' do
|
||||
|
|
|
@ -2,13 +2,22 @@
|
|||
|
||||
RSpec::Matchers.define :be_within_one_second_of do |expected_time|
|
||||
match do |actual_time|
|
||||
(actual_time - expected_time).abs <= 1
|
||||
(actual_time - expected_time).abs < 1
|
||||
end
|
||||
failure_message do |actual_time|
|
||||
"#{actual_time} is not within 1 second of #{expected_time}"
|
||||
end
|
||||
end
|
||||
|
||||
RSpec::Matchers.define :be_within_one_minute_of do |expected_time|
|
||||
match do |actual_time|
|
||||
(actual_time - expected_time).abs < 60
|
||||
end
|
||||
failure_message do |actual_time|
|
||||
"#{actual_time} is not within 1 minute of #{expected_time}"
|
||||
end
|
||||
end
|
||||
|
||||
RSpec::Matchers.define :eq_time do |expected_time|
|
||||
match do |actual_time|
|
||||
(actual_time - expected_time).abs < 0.001
|
||||
|
|
Loading…
Reference in New Issue