开发者

Stack overflow in Cucumber step definition when re-enqueueing delayed job in .perform

开发者 https://www.devze.com 2023-03-07 01:17 出处:网络
I\'ve got a job that is supposed to re-enqueue itself: class TestJob def perform Delayed::Job.enqueue(TestJob.new, {priority: 0, run_at: 5.minutes.from_now})

I've got a job that is supposed to re-enqueue itself:

class TestJob
  def perform
    Delayed::Job.enqueue(TestJob.new, {priority: 0, run_at: 5.minutes.from_now}) 
    true
  end
end

I'd like to call its perform method in a Cucumber step definition:

Then /^the job should run successfully/ do
  TestJob.new.perform.should == true
end

However, I get a stack overflow in this s开发者_如何学JAVAtep. What's causing this?


I'm sure there's a 'better' answer out there, but last time I tried to use the enqueue method, it was 'broken'. By that, I mean I couldn't get it to work.

I do something similar to what you're doing, except that I do

TestJob.new.delay(:run_at => 10.seconds.from_now).perform
0

精彩评论

暂无评论...
验证码 换一张
取 消