Sha256: 2b22f09ae3d5fda7d9958fad9324cbb8c5a7c51c7363e1d151d1f2492e3c1575

Contents?: true

Size: 785 Bytes

Versions: 76

Compression:

Stored size: 785 Bytes

Contents

require 'sucker_punch'

# Include this in your tests to simulate
# a fake job queue. Jobs won't be executed
# as they normal would be the thread pool.
# They'll instead be pushed to a fake queue
# to be checked in a test environment.
#
# Include in your test_helper.rb:
#
# require 'sucker_punch/testing'
#
# In your application code:
#
#   LogJob.perform_async(1, 2, 3)
#
# In your tests:
#
#   LogJob.jobs => [{ "args" => [1, 2, 3]]

module SuckerPunch
  module Job
    def self.jobs
      SuckerPunch::Queue.find_or_create(self.to_s)
    end

    def self.clear_all

    end
  end

  class Queue
    def self.find_or_create(name, _number_workers = 2, _num_jobs_max = nil)
      QUEUES.fetch_or_store(name) do
        []
      end
    end


    def kill
      true
    end
  end
end

Version data entries

76 entries across 76 versions & 2 rubygems

Version Path
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/testing.rb
harbr-0.2.10 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/testing.rb
harbr-0.2.9 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/testing.rb
harbr-0.2.8 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/testing.rb
harbr-0.2.7 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/testing.rb
harbr-0.2.6 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/testing.rb
harbr-0.2.5 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/testing.rb
harbr-0.2.4 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/testing.rb
harbr-0.2.3 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/testing.rb
harbr-0.2.2 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/testing.rb
harbr-0.2.1 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/testing.rb
harbr-0.2.0 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/testing.rb
harbr-0.1.99 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/testing.rb
harbr-0.1.98 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/testing.rb
harbr-0.1.97 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/testing.rb
harbr-0.1.96 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/testing.rb
harbr-0.1.95 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/testing.rb
harbr-0.1.94 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/testing.rb
harbr-0.1.93 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/testing.rb
harbr-0.1.91 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/testing.rb