Why is my rake task running twice in my test?

后端 未结 4 1678
悲&欢浪女
悲&欢浪女 2021-01-12 17:23

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/         


        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-12 18:02

    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
    

提交回复
热议问题