2

I have a rails 4.0.2 project and I'm using guard 4.7.5, guard-minitest 2.2.0, and spring 1.1.0.

When my Guardfile reads:

guard :minitest, spring: true do
  …
end

I get spring usage info when running guard.

As per the guard-minitest README, if my Guardfile reads:

guard :minitest, spring: 'rake test' do
  …
end

it runs all the default tests (see rake -T).

In fact, when running rake test by itself, it doesn't matter what I type afterwards, it always runs the default tests. Running bundle exec rake test [whatever] produces the same results.

What am I missing?

Boris Treukhov
  • 17,493
  • 9
  • 70
  • 91
partydrone
  • 507
  • 4
  • 15

3 Answers3

2
guard :minitest, spring: 'rake test' do
  …
end

Works on my setup (i.e., it runs just the right tests), though it doesn't show detailed stats in the notifier (just passing/not passing).

Do you have the right watchers in your do block? I'm basically using what guard init gave me, but I've uncommented the watchers under Rails 4, commenting out the rest. My complete minitest do block:

guard :minitest, spring: 'rake test' do

   #Rails 4
   watch(%r{^app/(.+)\.rb$})                               { |m| "test/#{m[1]}_test.rb" }
   watch(%r{^app/controllers/application_controller\.rb$}) { 'test/controllers' }
   watch(%r{^app/controllers/(.+)_controller\.rb$})        { |m| "test/integration/#{m[1]}_test.rb" }
   watch(%r{^app/views/(.+)_mailer/.+})                   { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
   watch(%r{^lib/(.+)\.rb$})                               { |m| "test/lib/#{m[1]}_test.rb" }
   watch(%r{^test/.+_test\.rb$})
   watch(%r{^test/test_helper\.rb$}) { 'test' }

end

I'm using:

  • ruby 2.0.0p451 (2014-02-24 revision 45167) [x86_64-linux]
  • guard-minitest-2.2.0
  • Guard version 2.6.0
  • Spring version 1.1.2
  • Rails 4.1.0
  • Minitest-5.5.5
Petr Skocik
  • 58,047
  • 6
  • 95
  • 142
0

As of Rails 4.1.6, it seems to work out of the box. I just added spring: true to my Guardfile and it worked. Correct tests are run when a file is modified and it does seem to start faster than without Spring.

My setup: Ruby 2.1, Rails 4.1.6, Guard 2.6.0, guard-minitest 2.3.2, Spring 1.1.3, minitest 5.4.2.

szeryf
  • 3,197
  • 3
  • 27
  • 28
0

Can you run bin\rake spring test?

If not, that's your problem as "spring: true" runs bin\rake.

Art
  • 781
  • 4
  • 13