posted an update

I made this into a Gem today for anyone else that feels like they should be testing their Whenever schedule. Which, judging by the lack of resources available when I was googling the issue, isn't a lot of people.

Anyway, its not on RubyGems yet, so you'll have to include it in your Gemfile like so:

# Gemfile

gem "shoulda-whenever", git: "git@github.com:MGerrior/shoulda-whenever.git", branch: "master"

After that, you can start testing schedules like this one:

# config/schedule.rb

every :friday, at: "12:00 PM", roles: [:app, :database] do
  rake "do:something:useful"
end

With specs like this:

# spec/schedule_spec.rb

describe "Schedule" do
  include Shoulda::Whenever

  let(:whenever) { Whenever::JobList.new(file: Rails.root.join("config", "schedule.rb").to_s) }

  it "does something useful every friday" do
    expect(whenever).to schedule_rake("do:something:useful")
      .every(:friday)
      .at("12:00 PM")
      .with_roles([:app, :database])
  end
end

Log in or sign up for Devpost to join the conversation.