Skip to content

Instantly share code, notes, and snippets.

@nateberkopec
Created June 2, 2017 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nateberkopec/3932fce995c9feddd411417fc9bf33bf to your computer and use it in GitHub Desktop.
Save nateberkopec/3932fce995c9feddd411417fc9bf33bf to your computer and use it in GitHub Desktop.
# Ever felt like your unit test suite was just too zippy? Slow that shit down immediately
# by running hundreds of jobs which have nothing to do with the behavior under test!
# This works even better if you have Sidekiq jobs enqueued in ActiveRecord callbacks!
module Sidekiq
class Testing
class << self
alias_method :my_tests_are_too_fast!, :inline!
end
end
end
# If you want faster tests (ew, who would want that? deviants.) you can use fake
# mode and call WorkerWhoseBehaviorIsUnderTest.drain, which will block until all
# enqueued jobs for that worker are processed. But that sounds hard, and adding
# Sidekiq::Testing.inline! to your test_helper is easy!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment