Database Cleaner not working in minitest rails

后端 未结 5 618
慢半拍i
慢半拍i 2021-01-02 14:48

My Minitest controller tests are working fine if I run them alone using rake minitest:controllers but when I run rake minitest:all then I get valid

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-02 15:05

    You can DRY up that repetition with this

    DatabaseCleaner.strategy = :truncation
    class MiniTest::Spec
      before :each do
        DatabaseCleaner.clean
      end
    end
    

    This example subclasses the spec runner, but you can pick your test environment of choice.

提交回复
热议问题