summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDaniel Worrall <Daniel.Worrall@hotmail.co.uk>2019-05-22 17:47:52 +0100
committerDaniel Worrall <Daniel.Worrall@hotmail.co.uk>2019-05-22 17:47:52 +0100
commitffe9604fc9f9e54ffa14c99ab45b6f8e4457f6f9 (patch)
treea0cd4da34b5cfd0e09751457fc563a31b637d58b /spec
parent3132621245630ac2ae345d331bb742ddeb88bfa2 (diff)
downloadtwitch-ffe9604fc9f9e54ffa14c99ab45b6f8e4457f6f9.tar.gz
twitch-ffe9604fc9f9e54ffa14c99ab45b6f8e4457f6f9.zip
Rate Limit Spec and less 1 letter vars
Diffstat (limited to 'spec')
-rw-r--r--spec/rate_limiter_spec.cr20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/rate_limiter_spec.cr b/spec/rate_limiter_spec.cr
new file mode 100644
index 0000000..345aa1a
--- /dev/null
+++ b/spec/rate_limiter_spec.cr
@@ -0,0 +1,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 \ No newline at end of file