diff --git a/README.md b/README.md index 866cf35..96d0db8 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ See the [Backing & Hacking blog post](https://www.kickstarter.com/backing-and-ha - [Customizing responses](#customizing-responses) - [RateLimit headers for well-behaved clients](#ratelimit-headers-for-well-behaved-clients) - [Logging & Instrumentation](#logging--instrumentation) +- [Testing](#testing) - [How it works](#how-it-works) - [About Tracks](#about-tracks) - [Testing](#testing) @@ -398,6 +399,16 @@ ActiveSupport::Notifications.subscribe(/rack_attack/) do |name, start, finish, r end ``` +## Testing + +### Disabling + +`Rack::Attack.enabled = false` can be used to either completely disable Rack::Attack in your tests, or to disable/enable for specific test cases only. + +### Test case isolation + +`Rack::Attack.reset!` can be used in your test suite to clear any Rack::Attack state between different test cases. + ## How it works The Rack::Attack middleware compares each request against *safelists*, *blocklists*, *throttles*, and *tracks* that you define. There are none by default.