Closed pirj closed 1 year ago
Ping
hey @pirj have you worked on this one? I like the idea and I'm curious if I can sneak the implementation :)
I haven't yet, but since you support the idea, I'll tackle it. For the implementation, I think of something very similar to this.
Yes, good to add negated matcher as well. It will be quite handy and readable to see something like:
expect { subject }
.to have_enqueued_sidekiq_job(FooJob)
.and have_enqueued_sidekiq_job(BarJob)
.and avoid_enqueuing_sidekiq_job(BazJob)
Released as https://github.com/pirj/rspec-enqueue_sidekiq_job https://rubygems.org/gems/rspec-enqueue_sidekiq_job
I've closed the PR. Please feel free to close the ticket as well.
I'd like this in rspec-sidekiq
and I've added it as a goal for v4. If you're still interested @pirj (I know it's been several years), feel free to re-open a PR. Otherwise I'll try and add a block syntax version using the same style expect { }.to enqueue_sidekiq_job(...)
I ended up creating https://github.com/pirj/rspec-enqueue_sidekiq_job Since we don’t use Sidekiq directly in my current project, I’m not so interested in actively maintaining the repo further. I’ll be happy if you take it over, borrow its code, or just include the gem as a runtime dependency, whatever you feel is right.
And thanks for the gem!
Thanks @pirj 👍 Appreciate it.
There is a slight problem with the existing
have_enqueued_sidekiq_job
matcher, specifically that it's prone to the incidental state error, unlikerspec-rails
's Active Job-orientedhave_enqueued_job
that is a block syntax matcher. E.g.:In the above example, the job was scheduled. But it would be scheduled no matter if
model.foo!
was called or not.I suggest adding a block-syntax
enqueue_sidekiq_job
matcher that would work similarly torspec-rails
's one:I can handle adding it if you have no objections on the idea.