3

I have placed all my specs in specs/*.rb.

However, when I run Minitest with ruby spec/**/*_spec.rb, only one file is run.

What gives?

Benjamin Tan Wei Hao
  • 9,621
  • 3
  • 30
  • 56

2 Answers2

3

This is not minitest specific, but Ruby. You are effectively running a ruby program which knows nothing about the program being run.

Ruby does not support running multiple files at once afaik, so if you want to get a similar result you could try something like:

for file in spec/**/*_spec.rb; do ruby $file; done

UPDATE: for what you want you should probably create a Rake task as described here

Community
  • 1
  • 1
Oscar Del Ben
  • 4,485
  • 1
  • 27
  • 41
  • Thanks Oscar. I checked that link out. The reason I wanted to run directly is because running a `rake test` seems super slow compared to say, your suggestion above. I tried to place it in `lib/tasks/minitest.rake` and running `rake test`, and it took ages. Any thoughts on that. – Benjamin Tan Wei Hao Aug 21 '12 at 05:36
  • It dependes on what you're loading on your Rake task. Rake by itself is fast. – Oscar Del Ben Aug 21 '12 at 05:43
1

You can use the testrbl third party gem to run multiple Minitest files on the command line. You could also use the mtest bin from maxitest extensions.

Using a for loop in bash will incur overhead of loading your application/library for every test you pass it. If you have just ten tests, and you're testing a Rails app that takes 5 seconds to boot, that's over a minute of totally unnecessary load time.

Gabe Martin-Dempesy
  • 7,687
  • 4
  • 33
  • 24