Questions tagged [rspec-sidekiq]

Simple testing of Sidekiq jobs via a collection of matchers and helpers

Simple testing of Sidekiq jobs via a collection of matchers and helpers

The official repository is https://github.com/philostler/rspec-sidekiq

26 questions
23
votes
2 answers

Writing tests for a sidekiq worker

I am using the rspec-sidekiq gem (https://github.com/philostler/rspec-sidekiq) to help test a worker I am writing, but for some reason my test keeps failing. Here is my Test: require 'spec_helper' describe CommunicationWorker do it { should…
dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189
5
votes
4 answers

Testing sidekiq perform_in with RSpec 3

RSpec 3 and sidekiq 3.2.1. And I have setup sidekiq and rspec-sidekiq properly. Suppose I have a worker called WeatherJob, which will change the weather status from sunny to rainy: class WeatherJob include Sidekiq::Worker def perform record_id …
Juanito Fatas
  • 9,419
  • 9
  • 46
  • 70
4
votes
1 answer

Testing that Sidekiq received correct delayed job

Inside of my User model I'm calling a delayed method: class User < ActiveRecord::Base def self.import_items ... User.delay.keep_only_user_cars(1) # "1" is just for testing end end And I'm trying to test it like so (using rspec-sidekiq…
Serge Vinogradoff
  • 2,262
  • 4
  • 26
  • 42
3
votes
1 answer

rspec-sidekiq: How to test "within_sidekiq_retries_exhausted_block" with another class method

I am using gem "rspec-sidekiq" to test "sidekiq_retries_exhausted". This is my worker: class PostListingsWorker include Sidekiq::Worker sidekiq_options :retry => 0 sidekiq_retries_exhausted do |msg| …
Eason Caizhen Liu
  • 459
  • 1
  • 5
  • 12
2
votes
0 answers

How to test or stub Sidekiq::Batch in RSPEC?

How to test or stub Sidekiq::Batch in RSPEC ? Please see got error in code below. rails_helper require 'spec_helper' require File.expand_path('../../config/environment', __FILE__) # Prevent database truncation if the environment is production …
aldrien.h
  • 3,437
  • 2
  • 30
  • 52
2
votes
2 answers

How to test a Sidekiq worker with RSpec?

I'm doing a test using RSPEC, and used Sidekiq for background jobs. Since, there's no generator for workers in rspec, not sure what to use. https://relishapp.com/rspec/rspec-rails/docs/generators require 'spec_helper' RSpec.describe TestWorker,…
aldrien.h
  • 3,437
  • 2
  • 30
  • 52
2
votes
1 answer

Sidekiq::Testing.fake! not faking Sidekiq::Queue

I have a simple worker that is accessing the size of its own queue: require 'sidekiq/api' class TestWorker include Sidekiq::Worker def perform(*args) Sidekiq::Queue.new('test').size end end I am then testing this worker: require…
Matthieu
  • 610
  • 7
  • 16
1
vote
1 answer

How to prevent Rails parallel tests and Sidekiq from calling Redis

I have a Rails application that is using Sidekiq for asynchronous jobs. I setup parallel testing to speed up my testing pipeline. This is working great but I have one major problem: Redis is bottlenecking with Sidekiq jobs trying to enqueue work…
1
vote
0 answers

rspec-sidekiq test case shows job in the wrong queue

I have an app running on rails 7 with sidekiq & redis. I have two jobs, a RequestJob, which is configured to be enqueued in "critical", and a PollingJob, created by the RequestJob, which is to be run in the "default" queue. I am trying to run a…
1
vote
0 answers

Sidekiq Batches, Ruby On Rails - How to write test with rspec for testing Job, where inside the batch is reopens from another Job

Class ParentWorker def perform(team_id) batch = Sidekiq::Batch.new batch.on(:complete, self.class, {:team_id => team_id}) batch.jobs do Team.find(team_id).assets.each do |asset| …
1
vote
1 answer

Testing enque of nested worker from another sidekiq worker

We have two workers as demonstrated below : class WorkerOne include Sidekiq::Worker def perform(arg_1, arg_2) # some calculation figure out arg_3 WorkerTwo.perform_async(arg_3, arg_2) end end class WorkerTwo include…
1
vote
0 answers

Set the current execution/retry number manually for a sidekiq job with ActiveJob

I have implemented retry-number dependent logic on my jobs. For example, when a job fails the first time, I restart it with additional params to handle the "clean up" of what the previous job execution may have done incorrectly. How can I run a…
Cyril Duchon-Doris
  • 12,964
  • 9
  • 77
  • 164
1
vote
0 answers

Testing sidekiq worker using rspec-sidekiq not working

This is my test code: require 'rails_helper' describe CookCookieWorker do let(:user) { FactoryGirl.create(:user) } let(:oven) { user.ovens.first } it { is_expected.to be_processed_in :cookies } it 'enqueues the cook cookies worker to be…
svelandiag
  • 4,231
  • 1
  • 36
  • 72
1
vote
0 answers

Rails; Autoload issue after installing Sidekiq: ArgumentError (A copy of Api::V1 has been removed from the module tree but is still active!):

I have a rails (v5.1) project in development, in which I recently installed Sidekiq. I now have an autoload issue, getting the subject argument error. I have done a fair bit of research which seem to boil down to this being a problem of "trying to…
bigmugcup
  • 1,321
  • 4
  • 15
  • 26
1
vote
1 answer

How can I check the code in the exception block?

I have Sidekiq worker. class DeliverSmsMessageWorker include Sidekiq::Worker def perform(sms_message_id) .... rescue StandardError => e Rails.logger.error("SmsMessageWorker ERROR: #{e}") Bugsnag.notify(e) end end And i write…
1
2