I am writing some integration tests for a Rails application. The application has a set of background tasks which are normally scheduled via cron
/whenever
. Since the cron
jobs only run every few hours, I want to run them directly from the integration tests rather than wait for the cron
jobs.
Each task is invoked by whenever
using:
runner "<module>.<task>"
i.e. using the rails runner.
My integration tests live in the API wrapper around the application, which is in a different directory to the Rails application.
The question therefore is, can I invoke rails runner
on a different directory from the current one, or invoke code in the Rails environment from within an rspec example outside of the Rails project?
Just running rails runner xxx
doesn't seem to work (just prints the usage banner) from anywhere other than the top level of the Rails app.