Skip to content

Instantly share code, notes, and snippets.

@pedantix
Created March 8, 2016 03:01
Show Gist options
  • Save pedantix/b6819772a7eb417e255b to your computer and use it in GitHub Desktop.
Save pedantix/b6819772a7eb417e255b to your computer and use it in GitHub Desktop.
RSpec for Rake
## Rake task test cheat sheet
require "rails_helper"
require "rake"
describe "cleanup" do
before :all do
Rake.application.rake_require "tasks/cleanup"
Rake::Task.define_task(:environment)
Rake::Task.define_task("cleanup:images")
end
describe ":images" do
let(:run_rake_task) do
Rake::Task["cleanup:images"].reenable
Rake.application.invoke_task "cleanup:images"
end
specify "reeps orphens for HomepageImages" do
expect(Cleanup::HomepageImageService).to receive(:reap_orphens)
expect(Cleanup::UserImageService).to receive(:reap_orphens)
run_rake_task
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment