Created
September 15, 2017 12:26
-
-
Save everton/e189577daa2dbb0086a69b9d68077bd9 to your computer and use it in GitHub Desktop.
IntegrationTest specialization to test rake tasks
This file contains hidden or 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
require 'rake' | |
class TasksTest < ActionDispatch::IntegrationTest | |
include ActionMailer::TestHelper | |
private | |
def self.task(t = nil) | |
return @task unless t | |
t = t.to_s | |
@task = Rake::Task[t] rescue nil | |
unless @task | |
Rails.application.load_tasks | |
@task = Rake::Task[t] | |
raise "Task \"#{t}\" not found" unless @task | |
end | |
@task | |
end | |
def task | |
self.class.task | |
end | |
def run_task! | |
task.reenable | |
task.execute | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment