Sha256: 4b4b5b7d388f6db92ae6a3975bf4513bd2ea8af00893c7c76442c03e35401bea

Contents?: true

Size: 869 Bytes

Versions: 4

Compression:

Stored size: 869 Bytes

Contents

module Sidekiq
  module Worker

    ##
    # The Sidekiq inline infrastructure overrides the 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
    #
    module ClassMethods
      alias_method :perform_async_old, :perform_async
      def perform_async(*args)
        new.perform(*args)
        true
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
kulesa-sidekiq-1.2.3 lib/sidekiq/testing/inline.rb
kulesa-sidekiq-1.2.2 lib/sidekiq/testing/inline.rb
sidekiq-1.2.1 lib/sidekiq/testing/inline.rb
sidekiq-1.2.0 lib/sidekiq/testing/inline.rb