mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-03-25 09:25:49 +00:00
Integration tests: less flakiness by sleeping more
This commit is contained in:
parent
cabadf3dc0
commit
2a7ae7d84d
1 changed files with 6 additions and 2 deletions
|
|
@ -9,6 +9,10 @@ describe Rack::Attack::Cache do
|
|||
end
|
||||
end
|
||||
|
||||
def sleep_until_expired
|
||||
sleep(@expires_in * 1.1) # Add 10% to reduce errors
|
||||
end
|
||||
|
||||
require 'active_support/cache/dalli_store'
|
||||
require 'active_support/cache/redis_store'
|
||||
cache_stores = [
|
||||
|
|
@ -47,7 +51,7 @@ describe Rack::Attack::Cache do
|
|||
describe "do_count after expires_in" do
|
||||
it "must be 1" do
|
||||
@cache.send(:do_count, @key, @expires_in)
|
||||
sleep @expires_in # sigh
|
||||
sleep_until_expired
|
||||
@cache.send(:do_count, @key, @expires_in).must_equal 1
|
||||
end
|
||||
end
|
||||
|
|
@ -62,7 +66,7 @@ describe Rack::Attack::Cache do
|
|||
describe "write after expiry" do
|
||||
it "must not have a value" do
|
||||
@cache.write("cache-test-key", "foobar", @expires_in)
|
||||
sleep @expires_in # tick... tick... tick...
|
||||
sleep_until_expired
|
||||
store.read(@key).must_be :nil?
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue