blob: 345aa1a9f7c584e207daf44a18c71c495fd94e56 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
require "./spec_helper"
describe RateLimiter do
describe "#rate_limited?" do
it "does the thing" do
limiter = RateLimiter(String).new
limiter.bucket(:foo, 5_u32, 1.seconds)
limiter.rate_limited?(:foo, "z64")
sleep 0.9
3.times do
limiter.rate_limited?(:foo, "z64")
end
sleep 0.2
3.times do
limiter.rate_limited?(:foo, "z64")
end
limiter.rate_limited?(:foo, "z64").should be_truthy
end
end
end
|