rubocop-rspec icon indicating copy to clipboard operation
rubocop-rspec copied to clipboard

Cop idea: Replace ActiveJob::TestHelper with activejob matchers

Open Darhazer opened this issue 8 years ago • 6 comments

I'm working on a code base that tests ActiveJobs with assert_enqued_job, assert_enqueued_with, etc, included by the ActiveJob::TestHelper, which is written with minitest. rpsec-rails however provide have_enqueued_job matcher

Darhazer avatar Feb 28 '17 09:02 Darhazer

I'm open to PRs for this. I have mentioned this in other PRs but I don't plan on implementing rails specific cops. It would also be nice if these things checked if rails cops were enabled

backus avatar Feb 28 '17 10:02 backus

@backus what about capybara-specific checks? I've ran in some wrong usages of capybara matchers

Darhazer avatar Mar 22 '17 15:03 Darhazer

As long as capybara support don't get in the way of normal rspec users I guess I'm fine with it. I don't use capybara so I wont be great as a primary reviewer for these.

backus avatar Mar 22 '17 18:03 backus

I also seen specs like expect(ActionMailer::MailDeliveryJob).to have_been_enqueued.with(Mailer, :something, :deliver_now) instead of using enqueued_mail matcher

Darhazer avatar Jan 05 '21 22:01 Darhazer

Did that spec fail, @Darhazer ?

pirj avatar Jan 06 '21 05:01 pirj

Nope, but it's overly expressive and leaks internals :)

Darhazer avatar Jan 06 '21 17:01 Darhazer