Skip to content

Commit 86ece75

Browse files
fix: properly mock time in ruby ci tests
1 parent 47876a8 commit 86ece75

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

test/finch_api/client_test.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,11 @@ def test_client_retry_after_seconds
126126
end
127127

128128
def test_client_retry_after_date
129+
time_now = Time.now
130+
129131
stub_request(:get, "http://localhost/employer/directory").to_return_json(
130132
status: 500,
131-
headers: {"retry-after" => (Time.now + 10).httpdate},
133+
headers: {"retry-after" => (time_now + 10).httpdate},
132134
body: {}
133135
)
134136

@@ -141,11 +143,11 @@ def test_client_retry_after_date
141143
max_retries: 1
142144
)
143145

146+
Thread.current.thread_variable_set(:time_now, time_now)
144147
assert_raises(FinchAPI::Errors::InternalServerError) do
145-
Thread.current.thread_variable_set(:time_now, Time.now)
146148
finch.hris.directory.list
147-
Thread.current.thread_variable_set(:time_now, nil)
148149
end
150+
Thread.current.thread_variable_set(:time_now, nil)
149151

150152
assert_requested(:any, /./, times: 2)
151153
assert_in_delta(10, Thread.current.thread_variable_get(:mock_sleep).last, 1.0)

0 commit comments

Comments
 (0)