Question

I have a scheduled task which is running every 1 minute using rufus scheduler. There is no issues with its execution. But when i try running rspec, the task runs as part of it and does not let the rspec complete. How to stop it from getting picked as part of specs

Était-ce utile?

La solution

Probably something like in your scheduler initializer:

if Rails.env.production?
  # start scheduler and schedule stuff...
end

EDIT

If you want to avoid running the scheduler in presence of Rspec you can do

if !defined?(Rspec)
  # start scheduler and schedule stuff...
end

It's a bit sad to mention the test framework in the code itself. It's probably better to say "let's not run the scheduler in test mode and do:

if !Rails.env.test?
  # start scheduler and schedule stuff...
end

So that the scheduler will run in production and development (or whatever env that is not test).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top