mercredi 24 juin 2015

How can I test objects in a new test directory with Minitest?

I use minitest-rails and here's how I test:

rake test test/models/publication.rb

And it works fine. I also use the database_cleaner gem, and it works fine. It ignores my seeded tables and clears everything else out.

Now, I have a test directory for POROs called test/poros. I want to be able to do this:

rake test test/poros/myobj_test.rb

Unfortunately, while that runs the file, it completely clears out my database, removing a ton of seeded values that takes about 15 minutes to recreate.

There's no reason why I shouldn't be able to run tests in that new directory. I followed the directions from Github:

# For testing POROs
Rails::TestTask.new("test:poros" => "test:prepare") do |t|
  t.pattern = "test/poros/**/*_test.rb"
end
Rake::Task["test:run"].enhance ["test:poros"]

Unfortunately, running rake test:poros obliterates all my seeded values, and that's a huge drag.

Aucun commentaire:

Enregistrer un commentaire