8

I start using MiniTest in my Rails project.

When I run spring rake test, the test works fine. But I can't run the test by guard-minitest.

bundle exec guard
05:03:24 - INFO - Guard::Minitest 2.4.6 is running, with Minitest::Unit 5.9.0!
05:03:24 - INFO - Running: all tests
Run options: -n spec/apis/user_spec.rb --seed 22566

# Running:



Finished in 0.004998s, 0.0000 runs/s, 0.0000 assertions/s.

0 runs, 0 assertions, 0 failures, 0 errors, 0 skips

05:03:25 - INFO - Guard is now watching at '/Users/ironsand/dev/my_project'

Guardfile

guard :minitest, spring: 'spring rake test' do
  watch(%r{^test/models/company_test.rb$})
  watch(%r{^test/(.*)\/?test_(.*)\.rb$})
  watch(%r{^lib/(.*/)?([^/]+)\.rb$})     { |m| "test/#{m[1]}test_#{m[2]}.rb" }
  watch(%r{^test/test_helper\.rb$})      { 'test' }
end

I wrote the test file name directory to avoid regular expression failer. The test file is in test/models/company_test.rb.

Where and how can I configure properly to watch the test files by guard?

ironsand
  • 14,329
  • 17
  • 83
  • 176
  • 1
    looks like guard is starting rspec rather then minitest: `Run options: -n spec/apis/user_spec.rb --seed 22566` – jethroo Sep 09 '16 at 22:57
  • @jethroo Where is the guard option defined? In `Guardfile` there is no config like that. – ironsand Sep 12 '16 at 17:47
  • can you try it with `spring: 'bundle exec spring rake test'` https://github.com/guard/guard-minitest/issues/114#issuecomment-69970527 – jethroo Sep 12 '16 at 18:46
  • Same as before the option is set for spec. `Run options: -n spec/apis/user_spec.rb --seed 4908` If I change directory name `spec` to `spec_temp` then works fine, but I want to keep the folder name. – ironsand Sep 13 '16 at 00:36

1 Answers1

0

I guess that the problem here is in watch blocks Could you try to set the block like that:

guard 'minitest', cmd: 'spring rake test' do
  watch('company.rb') { 'company_test.rb' }
  watch('company_test.rb')
enв
ilgam
  • 4,092
  • 1
  • 35
  • 28