Ruby on Rails 3 - 在 .execute 中重新排队延迟作业时,Cucumber 步骤定义中的堆栈溢出



我有一个应该重新排队的工作:

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

我想在黄瓜步骤定义中调用它的perform方法:

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

但是,在此步骤中出现堆栈溢出。这是什么原因造成的?

我确信有一个"更好"的答案,但上次我尝试使用 enqueue 方法时,它被"破坏了"。 我的意思是我无法让它工作。

我做的事情

和你正在做的事情类似,只是我做了

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

最新更新