Running groups programatically #420

Closed
rweng opened this Issue Apr 10, 2013 · 1 comment

Comments

Projects
None yet
2 participants
@rweng

rweng commented Apr 10, 2013

So there is this wiki entry on how to run guard with Rake tasks.

First, there seems to be a couple of things wrong with this entry. It seems as if the following is enough, since Guard.setup already runs Guard::Dsl.evaluate_guardfile:

task :run_all do
    require 'guard'
    Guard.setup
    Guard.run_all group: :all_specs
  end
end

However, I stumbled accross two issues here: First, when I have a default scope in my Guardfile (scope groups: :all_specs) I get the following error

11:52:38 - ERROR - Invalid Guardfile, original error is:
> [#] undefined method `empty?' for nil:NilClass

Removing the default scope results in the following error in the runner.rb.

$ rake specs:run_all
11:54:43 - INFO - Run all_specs
rake aborted!
undefined method `name' for :all_specs:Symbol
/Users/robin/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.6.2/lib/guard/runner.rb:174:in `block (2 levels) in scoped_guards'
/Users/robin/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.6.2/lib/guard/runner.rb:173:in `catch'
/Users/robin/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.6.2/lib/guard/runner.rb:173:in `block in scoped_guards'
/Users/robin/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.6.2/lib/guard/runner.rb:172:in `each'
/Users/robin/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.6.2/lib/guard/runner.rb:172:in `scoped_guards'
/Users/robin/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.6.2/lib/guard/runner.rb:53:in `block in run'
/Users/robin/.rvm/gems/ruby-2.0.0-p0/gems/lumberjack-1.0.3/lib/lumberjack.rb:27:in `unit_of_work'
/Users/robin/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.6.2/lib/guard/runner.rb:52:in `run'
/Users/robin/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.6.2/lib/guard.rb:238:in `block in run_all'
/Users/robin/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.6.2/lib/guard.rb:364:in `block in within_preserved_state'
....

It seems, as if the group must be provided with a Guard::Group. Using Guard.run_all group: Guard::Group.new(:all_specs) works.

Now I propose 3 things:

  1. ensure that scopes[:groups] contains Guard::Groups, even if run_all is passed Symbols.
  2. Update the wiki entry
  3. fix error that occurs when a scope is defined in the Guardfile (maybe we should create a new issue for that)

Now I might have gotten this all totally wrong, so looking forward to your opinion :)

@rymai

This comment has been minimized.

Show comment
Hide comment
@rymai

rymai Apr 10, 2013

Member

Hi Robin!

Thanks for your investigation on this! :)

About your 3 propositions:

  1. I agree that this should be possible to pass a default group as a symbol with scope groups: :all_specs. Feel free to open a pull-request specifically for this, or I could implement it if you prefer. Let me know.
  2. Go for it! :)
  3. You should definitely create a new issue for this!

Thank you!

Member

rymai commented Apr 10, 2013

Hi Robin!

Thanks for your investigation on this! :)

About your 3 propositions:

  1. I agree that this should be possible to pass a default group as a symbol with scope groups: :all_specs. Feel free to open a pull-request specifically for this, or I could implement it if you prefer. Let me know.
  2. Go for it! :)
  3. You should definitely create a new issue for this!

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment