spec-bench
spec-bench is (at the moment) a one-trick dog.
Usage
To use this, install it as a gem:
gem install spec-bench
Add this in your spec/spec_helper.rb file as an additional matcher to your config block:
config.include(Bench::Matchers)
You're good to go!
run_in
lambda { Post.performant_task }.should run_in(3.5.seconds)
Here we call .should on a Proc object and pass it run_in. This runs the given Proc, benchmarking how long it took. If this was longer than the given time it will error, meaning your performant_task isn't quite as performant as you thought.