1

I'm using dashing-rails https://github.com/gottfrois/dashing-rails in my project. It runs rufus-scheduler jobs on rails env load.

When I run my integration tests (rspec, capybara, selenium-driver), some of my tests randomly fail due to rufus-scheduler timeout errors. Is there a way to silence rufus-scheduler errors or disable rufus altogether in the test environment? I am not a fan of doing rails_env=test on my code base so any other solution would be appreciated.

Sample errors look like the following:

{ 283064 rufus-scheduler intercepted an error:
  283064   job:
  283064     Rufus::Scheduler::EveryJob "10s" {}
  283064   error:
  283064     283064
  283064     Timeout::Error
  283064     Waited 3 sec
Ace Dimasuhid
  • 1,032
  • 11
  • 33
  • I'm the author of rufus-scheduler, I can certify that I didn't write anything to break your integration tests. Consider choosing a smarter title for your issue. – jmettraux May 21 '14 at 05:48

1 Answers1

0

The rufus-scheduler #on_error could help. It's documented at https://github.com/jmettraux/rufus-scheduler#rufusscheduleron_errorjob-error

For example:

if rails_env == 'test' # set the handler only when testing...
  def Dashing.scheduler.on_error(job, error)
    # keep silent, do nothing
  end
end

You seem not to want to set the Rails env to "test" for your integration test so you have to find a way to determine when to override the scheduler #on_error method, that's your problem.

Also, rufus-scheduler doesn't raise instances of Timeout::Error, it raises instances of Rufus::Scheduler::TimeoutError so the errors you are seeing are not rufus-scheduler errors, they are merely intercepted by rufus-scheduler.

As commented above, as the author of rufus-scheduler, I did not write rufus-scheduler to read titles like "Rufus scheduler breaking integration tests", YOUR code assemblage breaks YOUR integration tests. Do take responsibility.

jmettraux
  • 3,511
  • 3
  • 31
  • 30
  • Thanks for this. It lead me to where I'm supposed to check next. I do apologise for not thinking the title through while I was posting it. Didn't intend it to sound as it did. I'll be more mindful in my future questions. – Ace Dimasuhid May 21 '14 at 07:53
  • Feel free to change the title and/or to accept my answer then. Thanks in advance. – jmettraux May 21 '14 at 08:38