wspurgin / rspec-sidekiq

RSpec for Sidekiq

Home Page:https://github.com/wspurgin/rspec-sidekiq

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deprecation warning not shown / have_enqueued_jobs name clash

leoc opened this issue · comments

I am using rspec-rails 3.4.2 and was wondering why I get the following error, while trying to test job creation in a after_create callback.

ArgumentError:
       have_enqueued_jobs only supports block expectations

rspec-rails defines a have_enqueued_job matcher, which seems to introduce problems with rspec-sidekiq. I suppose this check does not work:

https://github.com/philostler/rspec-sidekiq/blob/3ef52ce9ae7b3b5214a9b479318ad3c244ab7c65/lib/rspec/sidekiq/matchers/have_enqueued_job.rb#L7-L10

Also I suggest only guarding the deprecation warning with the if clause. The alias should be defined in any case, no?

I'm guessing that the check is fine, but that the issue is with having both libraries try to define have_enqueued_job. It seems like the best way to deal with this would be having rspec-sidekiq define have_enqueued_sidekiq_job and only alias in the case that rspec-rails < 3.4.

The issue with doing it that way is that someone can have a bunch of tests that work, and then upgrade rspec-rails and suddenly everything is broken. @wpolicarpo || @philostler thoughts?

@packrat386 @leoc I think #105 addresses the issue the right way. I'd say that the only problem (not a real problem, though) is that have_enqueued_job should be delegating to have_enqueued_sidekiq_job instead of instantiating HaveEnqueuedJob itself.