I have a rake task test that I setup following the only examples I could find online.
It looks like this:
require \'test_helper\' require \'minitest/
Turns out that rake is already required and initialized when the test runs so all of the following lines need to be removed or the task gets defined twice and runs twice even if you only invoke it once.
require 'minitest/mock' require 'rake' ... Rake.application.init Rake.application.load_rakefile