Sha256: 64bcd4be1c09ff3e2b5c42b91a7140be77f991a11b231d37670c662ff6d652ec

Contents?: true

Size: 907 Bytes

Versions: 8

Compression:

Stored size: 907 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(*Sidekiq.load_json(Sidekiq.dump_json(args)))
        true
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sidekiq-2.2.1 lib/sidekiq/testing/inline.rb
sidekiq-2.2.0 lib/sidekiq/testing/inline.rb
sidekiq-2.1.1 lib/sidekiq/testing/inline.rb
sidekiq-2.1.0 lib/sidekiq/testing/inline.rb
sidekiq-2.0.3 lib/sidekiq/testing/inline.rb
sidekiq-2.0.2 lib/sidekiq/testing/inline.rb
sidekiq-2.0.1 lib/sidekiq/testing/inline.rb
sidekiq-2.0.0 lib/sidekiq/testing/inline.rb