Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 5 issues: invalid option: --guard #142

Open
ZombieHarvester opened this issue Jul 29, 2016 · 15 comments
Open

Rails 5 issues: invalid option: --guard #142

ZombieHarvester opened this issue Jul 29, 2016 · 15 comments

Comments

@ZombieHarvester
Copy link

ZombieHarvester commented Jul 29, 2016

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: rails/rails#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 spring: 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 see #130

@e2
Copy link
Contributor

e2 commented Jul 29, 2016

@tmichel - any ideas for problem 1?

@e2
Copy link
Contributor

e2 commented Jul 29, 2016

For problem 2: This probably doesn't help much, it could give ideas: #133

Can you create a mini project to recreate the problem? (I don't have time right now, but if I had a small repo with this issue, I could check exactly what is going on).

@e2
Copy link
Contributor

e2 commented Jul 29, 2016

Maybe also related: #130

@ZombieHarvester
Copy link
Author

thanks @e2, it was #130. Using spring: "bin/rails test" solved problem 2. Maybe it needs to be in the readme?

@ZombieHarvester ZombieHarvester changed the title Rails 5 issues: invalid option: --guard; and always runs all tests when spring: true Rails 5 issues: invalid option: --guard Jul 29, 2016
@tmichel
Copy link

tmichel commented Jul 30, 2016

For problem 1 the cause is definitely the linked Rails issue (rails/rails#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.

0x7466 added a commit to 0x7466/LeSSL that referenced this issue Aug 18, 2016
chesterbr added a commit to chesterbr/toronto-transit-time that referenced this issue Oct 19, 2016
@taq
Copy link

taq commented Jan 11, 2017

Guys? Seems that 6 months after this issue was open seems that even on the most recent version of the gems (rails, guard, guard-minitest) is still failing to run. Using spring: true, as said, works to run Guard, but everytime it runs all the tests, and becomes a little complicated ... we need to wait the resolution on the Rails side, right?

@tmichel
Copy link

tmichel commented Jan 12, 2017

For me the following setup works flawlessly:

  • guard (2.14.0)
  • guard-minitest (2.4.6)
  • minitest (5.10.1)
  • rails 5.0.1
# in Guardfile
guard :minitest, spring: "bin/rails test", all_on_start: false do
  # usual rules for Rails apps
end

@taq
Copy link

taq commented Jan 12, 2017

Hey @tmichel will check it out!

@Mirv
Copy link

Mirv commented Feb 1, 2017

@tmichel thanks! Worked for me

@taq
Copy link

taq commented Feb 1, 2017

Worked for me too, thanks @tmichel :-)

@a-b
Copy link

a-b commented Feb 23, 2017

Any better solution exist?

@seanlerner
Copy link

Paring down @tmichel's solution, I managed to get away with just:

guard :minitest, spring: 'rails test' do
  # rules
end

@starrychloe
Copy link

This is occurring for me too. There's nothing remarkable about my app. I'm not even using Spring. I'm using the default Guardfile generated with bundle exec guard init minitest.

>bundle exec guard
  Please add the following to your Gemfile to avoid polling for changes:
    gem 'wdm', '>= 0.1.0' if Gem.win_platform?
20:33:43 - INFO - Run 'gem install win32console' to use color on Windows
20:33:44 - INFO - Guard::Minitest 2.4.6 is running, with Minitest::Unit 5.10.1!

20:33:44 - INFO - Running: all tests
C:/ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/test_unit/minitest_plugin.rb:57:in `plugin_rails_options': invalid option: --guard (OptionParser::InvalidOption)
        from C:/ruby23/lib/ruby/gems/2.3.0/gems/minitest-5.10.1/lib/minitest.rb:200:in `block (2 levels) in process_args'
        from C:/ruby23/lib/ruby/gems/2.3.0/gems/minitest-5.10.1/lib/minitest.rb:198:in `each'
        from C:/ruby23/lib/ruby/gems/2.3.0/gems/minitest-5.10.1/lib/minitest.rb:198:in `block in process_args'
        from C:/ruby23/lib/ruby/gems/2.3.0/gems/minitest-5.10.1/lib/minitest.rb:168:in `new'
        from C:/ruby23/lib/ruby/gems/2.3.0/gems/minitest-5.10.1/lib/minitest.rb:168:in `process_args'
        from C:/ruby23/lib/ruby/gems/2.3.0/gems/minitest-5.10.1/lib/minitest.rb:122:in `run'
        from C:/ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.2/lib/rails/test_unit/minitest_plugin.rb:72:in `run'
        from C:/ruby23/lib/ruby/gems/2.3.0/gems/minitest-5.10.1/lib/minitest.rb:62:in `block in autorun'
[1] guard(main)>  Guard is now watching at ...

Rails tests work fine by themselves.

>rails test
Run options: --seed 20239

# Running:
...

Rails 5.0.2, Windows

@raucao
Copy link

raucao commented Jun 28, 2018

I get this error without Rails, in just a plain Ruby gem, that I created with the bundler gem command and default minitest layout. When I run it with guard -d I see that it indeed does add an additional -- --guard option to the command and that minitest does not accept it.

@yb66
Copy link

yb66 commented Jul 9, 2019

I also get this error and I'm not using Rails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants