TurtleHunter

relevant gif

Turtle Hunter (https://github.com/doximity/turtle_hunter) is a gem that enforces speed requirements on RSpec specs. Any spec that takes longer than its allowed threshold will be failed. Thresholds can be more lenient in CI. This reduces/eliminates the possibility that a spec passed on your local machine but failed in CI due to hardware/software/latency differences.

Installation

Add this line to your application's Gemfile:

gem "turtle_hunter", github: "doximity/turtle_hunter"

And then execute:

$ bundle

Or install it yourself as:

$ gem install turtle_hunter

Set FAIL_SLOW to true, run specs.

Configuration

  • FAIL_SLOW
    • default: nil
    • set this to true to invoke turtle hunter

The following test ENV vars can be setup for turtle_hunter, overriding turtle_hunter's defaults. All times are in milliseconds.

  • SKIP_FLAG
    • default: :allowed_slow_test
    • The name of the flag you give specs you want turtle_hunter to skip over
  • MODEL_THRESHOLD
    • default: 2000
    • Threshold at which model specs will fail.
  • CONTROLLER_THRESHOLD
    • default: 5000
    • Threshold at which controller specs will fail.
  • FEATURE_THRESHOLD
    • default: 20000
    • Threshold at which feature specs will fail.
  • ELSE_THRESHOLD
    • default: 5000
    • Threshold at which all type other specs will fail.
  • LENIENCE_FLAG
    • default: nil
    • If set to an environment variable that will be present in CI, ie ENV['CIRCLECI'], this flag will enable "lenient" turtle_hunting.
  • LENIENCE_LEVEL
    • default: 2.0
    • If enabled via LENIENCE_FLAG, the factor at which specs are leniently watched. A LENIENCE_LEVEL of 2 and LENIENCE_FLAG of 'CIRCLECI' will enlarge the allowed threshold by 2x of all specs that run on CircleCI.## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/doximity/turtle_hunter.

License

The gem is available as open source under the terms of the MIT License.