Skip to content

Commit

Permalink
Add a new spec for new retry logic
Browse files Browse the repository at this point in the history
  • Loading branch information
giladshanan committed May 9, 2024
1 parent 8619853 commit 20d8519
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions spec/system/research_safety/scishield/scishield_timeout_spec.rb
Expand Up @@ -18,6 +18,23 @@
)
end

describe "api_unavailable?" do
before do
# Raise a Net::OpenTimeout error when calling ScishieldApiClient#invalid_response?
allow_any_instance_of(ResearchSafetyAdapters::ScishieldApiClient).to(
receive(:invalid_response?).and_raise(Net::OpenTimeout)
)
# We just want to test the retry logic, so we'll set the retry_max to 2
allow_any_instance_of(ResearchSafetyAdapters::ScishieldTrainingSynchronizer).to(
receive(:retry_max).and_return(2)
)
end

it "returns true instead of failing with a Net::OpenTimeout error" do
expect(ResearchSafetyAdapters::ScishieldTrainingSynchronizer.new.api_unavailable?).to be true
end
end

describe "Net::OpenTimeout errors when the user does not have a ScishieldTraining record" do
before do
# This will cause ResearchSafetyAdapters::ScishieldApiClient#certifications_for
Expand Down

0 comments on commit 20d8519

Please sign in to comment.