DEV Community

loading...

How to test whenever config

vasily profile image Vasily Polovnyov ・1 min read

I recently made a typo in the whenever (Ruby cron jobs manager) — config:

# config/schedule.rb
every 1.day, at: "03:30 am", roles: %i(backupable) do
  rake %( # %( should be %w(
    backup:db
    backup:assets
  ).join(" ")
end
Enter fullscreen mode Exit fullscreen mode

It broke deployment pipeline with the following error:

NoMethodError: undefined method `join' for "backup:db backup:assets":String
Enter fullscreen mode Exit fullscreen mode

To avoid this in the future, we need at least minimal validation of the whenever config. The solution is simple, just run this command on CI:

bundle exec whenever
Enter fullscreen mode Exit fullscreen mode

If there are problems in config, it will return an error. If there are no problems, it will display the resulting crontab.

Discussion (0)

pic
Editor guide