guard-minitest: Rails 5 issues: invalid option: --guard
Upgraded to Rails 5 and guard-minitest v2.4.6 today. Got two issues:
Problem 1
bundle exec guard with guard :minitest do i get the following error:
/Users/me/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/test_unit/minitest_plugin.rb:57:in `plugin_rails_options': invalid option: --guard (OptionParser::InvalidOption)
from /Users/me/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/minitest-5.9.0/lib/minitest.rb:200:in `block (2 levels) in process_args'
from /Users/me/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/minitest-5.9.0/lib/minitest.rb:198:in `each'
from /Users/me/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/minitest-5.9.0/lib/minitest.rb:198:in `block in process_args'
from /Users/me/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/minitest-5.9.0/lib/minitest.rb:168:in `new'
from /Users/me/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/minitest-5.9.0/lib/minitest.rb:168:in `process_args'
from /Users/me/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/minitest-5.9.0/lib/minitest.rb:122:in `run'
from /Users/me/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/minitest-5.9.0/lib/minitest.rb:62:in `block in autorun'
it might be related to the following issue: https://github.com/rails/rails/issues/25046 and #141
if i add spring to the guardfile guard :minitest, spring: true do then invalid option: --guard doesn’t appear and all tests run . Also rolling back to v2.4.5 solves the issue.
Problem 2
with see #130spring: true i cannot get specific test to run. Having watch(%r{^test/.+_test\.rb$}) in guardfile and updating for example user_test.rb it runs all tests. Without spring it runs only user_test.rb
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 7
- Comments: 15 (5 by maintainers)
Commits related to this issue
- Update acme-client dependency and other gems. Remove Guard gem temporarily because of issues. https://github.com/guard/guard-minitest/issues/142 — committed to 0x7466/LeSSL by 0x7466 8 years ago
- Fix guard for Rails 5 see: https://github.com/guard/guard-minitest/issues/142 — committed to chesterbr/toronto-transit-time by chesterbr 8 years ago
- Fix `invalid option: --guard (OptionParser::InvalidOption)` Ref: https://github.com/guard/guard-minitest/issues/142 — committed to rastamhadi/sendgrid_notification by rastamhadi 7 years ago
- Fix `invalid option: --guard (OptionParser::InvalidOption)` Ref: https://github.com/guard/guard-minitest/issues/142 — committed to rastamhadi/sendgrid_notification by rastamhadi 7 years ago
For me the following setup works flawlessly:
For problem 1 the cause is definitely the linked Rails issue (https://github.com/rails/rails/issues/25046). Rails has its own minitest runner and that parses options ahead of time and minitest plugins could not register their own flags. This probably breaks any other plugin that uses custom command line flags.
Using a flag to signal the plugin is pretty much the recommended minitest way. I don’t know if the mentioned Rails bug should be “supported” by guard-minitest and worked around somehow.
thanks @e2, it was #130. Using
spring: "bin/rails test"solved problem 2. Maybe it needs to be in the readme?I get this error without Rails, in just a plain Ruby gem, that I created with the
bundler gemcommand and default minitest layout. When I run it withguard -dI see that it indeed does add an additional-- --guardoption to the command and that minitest does not accept it.