Celluloid runs in a new thread, so it runs on a new transaction. Therefore we cannot test what was done in this transaction.
If you are not using any Celluloid callbacks then a simple unthreaded baseclass can help:
class BackgroundJobTestable
def perform
...
end
class BackgroundJob < BackgroundJobTestable
include SuckerPunch::Job
workers 2
end
An alternative way to fix this is to disable AR multithreading support via a mocking library like mocha … this will break any code that truly runs in parallel, but if you only run 1 code path at a time this should work fine.
ActiveRecord::Base.stubs(connection: ActiveRecord::Base.connection)