Are you also using Resque to read from SQS? If so, you can use an around
hook to enable Resque's inline mode. (This way Resque executes the jobs right away without actually queueing them.)
around do |example|
Resque.inline = true
example.run
Resque.inline = false
end
Based on your code, you could then either check to see if the other worker has done its job (e.g. if it has created a record by checking the related records' count difference), or you could just use RSpec's have_received method to make sure the other worker has been queued by Resque.
allow(Resque).to receive(:enqueue)
SQSWorker.perform
expect(Resque).to have_received(:enqueue).with(
OtherWorker,
optional: 'args'
)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…