mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
fd0232eb15
In addition to requiring 'sidekiq/testing' and 'sidekiq/testing/inline', a user can also call the following methods to control the test harness: Sidekiq::Testing.fake! Sidekiq::Testing.inline! Sidekiq::Testing.disable! Each of the above methods also accepts a block to execute within that context before reverting to the state present before method invocation. To query the current state, use the following methods: Sidekiq::Testing.enabled? Sidekiq::Testing.disabled? Sidekiq::Testing.fake? Sidekiq::Testing.inline? Closes #1053
28 lines
608 B
Ruby
28 lines
608 B
Ruby
require 'sidekiq/testing'
|
|
|
|
##
|
|
# The Sidekiq inline infrastructure overrides perform_async so that it
|
|
# actually calls perform instead. This allows workers to be run inline in a
|
|
# testing environment.
|
|
#
|
|
# This is similar to `Resque.inline = true` functionality.
|
|
#
|
|
# Example:
|
|
#
|
|
# require 'sidekiq/testing/inline'
|
|
#
|
|
# $external_variable = 0
|
|
#
|
|
# class ExternalWorker
|
|
# include Sidekiq::Worker
|
|
#
|
|
# def perform
|
|
# $external_variable = 1
|
|
# end
|
|
# end
|
|
#
|
|
# assert_equal 0, $external_variable
|
|
# ExternalWorker.perform_async
|
|
# assert_equal 1, $external_variable
|
|
#
|
|
Sidekiq::Testing.inline!
|