Skip to content

Instantly share code, notes, and snippets.

@gabebw
Created July 13, 2011 16:13
Show Gist options
  • Save gabebw/1080650 to your computer and use it in GitHub Desktop.
Save gabebw/1080650 to your computer and use it in GitHub Desktop.
Test Rake task
require 'spec_helper'
describe "Rake tasks" do
def fake_rake_application
app = Rake::Application.new
Rake.application = app
Rake::Task.define_task('environment'){}
app
end
before(:all) do
@rake = fake_rake_application
tasks = Dir[Rails.root.join('lib', 'tasks', '**', '*')]
tasks.each{|t| load t }
end
after(:all) do
Rake.application = nil
end
context "the backup task" do
it "runs when :cron is run" do
HerokuBackupTask.should_receive(:execute).once
@rake['cron'].invoke
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment