Sha256: d7a20ea22e0b0831889eac6a81c3bd023cdaa45ed5b4a0a58fce4d8066929270

Contents?: true

Size: 778 Bytes

Versions: 3

Compression:

Stored size: 778 Bytes

Contents

require 'helper'
require 'sidekiq/worker'

class TestTesting < MiniTest::Unit::TestCase
  describe 'sidekiq testing' do

    class DirectWorker
      include Sidekiq::Worker
      def perform(a, b)
        a + b
      end
    end

    it 'stubs the async call when in testing mode' do
      begin
        # Override Sidekiq::Worker
        require 'sidekiq/testing'
        assert_equal 0, DirectWorker.jobs.size
        assert DirectWorker.perform_async(1, 2)
        assert_equal 1, DirectWorker.jobs.size
      ensure
        # Undo override
        Sidekiq::Worker::ClassMethods.class_eval do
          remove_method :perform_async
          alias_method :perform_async, :perform_async_old
          remove_method :perform_async_old
        end
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sidekiq-0.8.0 test/test_testing.rb
sidekiq-0.7.0 test/test_testing.rb
sidekiq-0.6.0 test/test_testing.rb