Created
March 8, 2016 03:01
-
-
Save pedantix/b6819772a7eb417e255b to your computer and use it in GitHub Desktop.
RSpec for Rake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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