You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# bad - `perform` method is called directly on an implicitly defined subjectRSpec.describeSomeJobdo# implicitly defined `subject` is `SomeJob.new`it'updates user status'doexpect{subject.perform(user)}.tochange{user.status}.to(:updated)}endend# bad - `perform` method is called directly on a job instanceRSpec.describeSomeJobdoit'updates user status'doexpect{SomeJob.new.perform(user)}.tochange{user.status}.to(:updated)}endend# goodRSpec.describeSomeJobdoit'updates user status'doexpect{SomeJob.perform_now(user)}.tochange{user.status}.to(:updated)}endend
# bad - unnecessary roundtrip to RedisRSpec.describeSomeJobdoit'updates user status'doexpectdoSomeJob.perform_later(user)perform_scheduled_jobsend.tochange{user.status}.to(:updated)}endend# goodRSpec.describeSomeJobdoit'updates user status'doexpect{SomeJob.perform_now(user)}.tochange{user.status}.to(:updated)}endend
The text was updated successfully, but these errors were encountered:
ydakuka
changed the title
Cop idea: Don’t use job.perform or job_class.new.perform in specs
Cop idea: Don’t use job.perform or job_class.new.perform, prefer perform_now to perform_later when testing jobs
Sep 16, 2023
Reference:
https://github.com/toptal/active-job-style-guide#perform
https://github.com/toptal/active-job-style-guide#perform_later
The text was updated successfully, but these errors were encountered: