guard / guard-minitest

Guard::Minitest automatically run your tests (much like autotest)
https://rubygems.org/gems/guard-minitest
MIT License
249 stars 88 forks source link

Guard-minitest does not seem to work with spring in a Rails 4 engine. #114

Closed davidmles closed 9 years ago

davidmles commented 10 years ago

Guard-minitest does not seem to work with spring in a Rails 4 engine.

Steps to reproduce it:

rails plugin new example --mountable
cd example/
echo "gem 'guard-minitest', group: :development" >> Gemfile
bundle
bundle exec guard init minitest
bundle exec guard

Here it runs the test/example_test.rb sample test successfully:

01:27:50 - INFO - Guard is using TerminalTitle to send notifications.
01:27:50 - INFO - Guard::Minitest 2.3.0 is running, with Minitest::Unit 5.3.4!
01:27:50 - INFO - Running: all tests
Run options: --seed 27937

# Running:

.

Finished in 0.004659s, 214.6383 runs/s, 214.6383 assertions/s.

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

01:27:52 - INFO - Guard is now watching at '/Users/david/Sites/example'

Now when editing Guardfile and changing guard :minitest do to guard :minitest, spring: true do, the test is not run anymore:

01:28:45 - INFO - Run all
01:28:45 - INFO - Running: all tests

Nothing is run.

Spring.application_root = './test/dummy'

...does not help either.

genericsteele commented 10 years ago

Interesting...I'll need to have a look at how Spring handles engines.

aspiers commented 10 years ago

Doesn't work for me either:

Using /home/adam/.rvm/gems/ruby-1.9.3-p392 with gemset myapp
19:11:57 - WARN - Guard::RSpec DEPRECATION WARNING: The :spring option is deprecated. Please customize the new :cmd option to fit your need.
19:11:57 - INFO - Guard is using Libnotify to send notifications.
19:11:57 - INFO - Guard is using Emacs to send notifications.
19:11:57 - INFO - Guard is using Tmux to send notifications.
19:11:57 - INFO - Guard is using TerminalTitle to send notifications.
19:11:57 - INFO - LiveReload is waiting for a browser to connect.
19:11:57 - INFO - Guard::Minitest 2.3.0 is running, with Minitest::Unit 4.7.5!
19:11:57 - INFO - Guard::RSpec is running
19:11:57 - INFO - Bundle already up-to-date
19:11:57 - INFO - Guard is now watching at '/home/adam/rails/myapp'

Frame number: 0/0
[1] guard(main)> minitest
19:12:00 - INFO - Run Minitest
19:12:00 - INFO - Running: all tests
Warning: You're using Rubygems 1.8.25 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better startup performance.
Run options: -n spec/models/person_spec.rb --seed 5542

# Running tests:

Finished tests in 0.011478s, 0.0000 tests/s, 0.0000 assertions/s.

0 tests, 0 assertions, 0 failures, 0 errors, 0 skips
Coverage report generated for Functional Tests, RSpec to /home/adam/rails/myapp/coverage. 833 / 912 LOC (91.34%) covered.
genericsteele commented 10 years ago

@davidmles I was able to get this working, but I need a sanity check. I needed the spring.rb config file pointing to the dummy app along with a change to the spring command. Can you try to run this again, but with spring: 'bundle exec spring rake test' as the spring command in the Guardfile? Also any output from bundle exec guard --debug would be helpful.

config/spring.rb

Spring.application_root = './test/dummy'

Guardfile

guard :minitest, spring: 'bundle exec spring rake test' do
genericsteele commented 10 years ago

I have a hunch that there is some command gobbling up actual errors instead of raising them, which causes zero tests to be run here and #97.

I'd welcome any theories/suggestions/pull requests.

szeryf commented 10 years ago

Not sure if it helps anyone, but with 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.

sunnyrjuneja commented 9 years ago

It also seems to be working fine with rails 4.2, ruby 2.1.5, Guard 2.10.5, guard-minitest 2.3.2, spring 1.2.0, and minitest 5.5.0. It might be okay to close this issue now.

e2 commented 9 years ago

If anyone can create a GH repo reproducing this, I would look into it.

bikramwp commented 9 years ago

Just tested this in a Rails engine. Here is GH repo reproducing the problem spring: 'bundle exec spring rake test' works but spring: true does not work.

Versions in use: rails-4.2.0 spring-1.2.0 minitest-5.5.1 guard-2.11.1 guard-minitest-2.3.2

e2 commented 9 years ago

It's because bin/rake doesn't exist...

There should be a message in guard-minitest for this. I'll try and cook something up.

e2 commented 9 years ago

I've released guard-minitest 2.4.2, which shows an error in this scenario (instead of a silent failure).

So, I'm closing this.

Let me know if there are any other issues.

e2 commented 9 years ago

@bikramwp - thanks so much for the repo to reproduce this. I wouldn't have worked this out without it.

genericsteele commented 9 years ago

@e2 Good find and good fix. Thanks for picking this one back up.

e2 commented 9 years ago

@genericsteele - I don't know if Errno::ENOENT is a good choice. But it was the least confusing that I could think of.

duarme commented 9 years ago

For some reason this issue occurs if there is spec folder along with the test one. I was migrating from rspec to minitest and I was trying to solve this issue but I gave up. Anyway, as soon as I renamed the spec folder the issue was fixed... weird.