How can I make my other tests pass after implementing Throttle

266 Views Asked by At

I am working on a task that requires me to throttle payment requests, limiting to one payment per few seconds. The task is well done and working as should, even the tests to confirm the throttle is well implemented are working as should. My only problem is that it's making other payment tests fail.

I have been looking at different articles and they say adding Rack::Attack.enabled = false can fix that for me but it's clearly not because my tests are still failing, tests are still failing.

Below are the articles I've read and implemented and nothing works so far:

Has anyone worked with rack-attack and experienced this?

This is the code I added and everything is still failing: Added Rack::Attack.enabled = false on config/environments/test.rb and I added this on the test file to test it:

before do
 # Enable Rack::Attack for this test
 Rack::Attack.enabled = true
 Rack::Attack.reset!
end

after do
 # Disable Rack::Attack for future tests so it doesn't
 # interfere with the rest of our tests
 Rack::Attack.enabled = false
end

Am I missing something?

0

There are 0 best solutions below