Can't use guard-minitest in Rails
Asked Answered
A

1

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?

Abell answered 9/9, 2016 at 22:11 Comment(4)
looks like guard is starting rspec rather then minitest: Run options: -n spec/apis/user_spec.rb --seed 22566Rosemonde
@Rosemonde Where is the guard option defined? In Guardfile there is no config like that.Abell
can you try it with spring: 'bundle exec spring rake test' github.com/guard/guard-minitest/issues/…Rosemonde
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.Abell
L
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в
Lusty answered 5/11, 2016 at 11:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.