5

I have a custom environment called 'reports' that is setup to hit a slave database. I am trying to configure some cron jobs using the Whenever gem and want to test them in development before I deploy. Is there any way to test cron jobs in development? Is there anyway I could schedule them locally and then start my reports server and see if they run? Thank You!

Flip
  • 6,233
  • 7
  • 46
  • 75
BC00
  • 1,589
  • 3
  • 29
  • 47

1 Answers1

3

I would start off by reviewing how the gem itself (whenever gem) is conducting their tests. This is an extract from one of their functional test:

context "weekday at a (single) given time" do
    setup do
      @output = Whenever.cron \
      <<-file
        set :job_template, nil
        every "weekday", :at => '5:02am' do
          command "blahblah"
        end
      file
    end

    should "output the command using that time" do
      assert_match '2 5 * * 1-5 blahblah', @output
    end
  end
fmendez
  • 7,250
  • 5
  • 36
  • 35
  • The only problem with this way of doing that is that you're not really using the code on `schedule.rb`, so if you change the `schedule.rb` code, the tests will still pass and the generated cron output might be incorrect – Oscar Mederos Oct 07 '15 at 00:46