Guard-rspec and ember does not works well together

Viewed 276

Rails 4.2.7 guard-rspec 4.7.3

Since I installed ember-cli-rails, the ember app prevent guard-spec to run and triggers hundreds of errors. Here is one error :

Directory: /home/sylvain/dev/placedemarche/marketadmin/tmp/broccoli_merge_trees-output_path-rlX3b4rm.tmp/marketadmin/tests/unit

    is already being watched through: /home/sylvain/dev/placedemarche/marketadmin/tmp/broccoli_persistent_filterbabel__babel_marketadmin-output_path-Nv8C3Z67.tmp/marketadmin/tests/unit

    MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
    ** ERROR: directory is already being watched! **

I tried multiple things in the guardfile, even removing all of the watch :

guard 'rspec',:cli => "--drb --format progress",all_after_pass: false do
  # ignore /marketadmin/ 
  # watch(%r{^spec/(.+)_spec\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
  # watch(%r{^lib/(.+)\.rb$})     { |m| "spec/lib/#{m[1]}_spec.rb" }
  # watch('spec/spec_helper.rb')  { "spec" }

  # # Rails example
  # watch(%r{^app/(.+)\.rb$})                           { |m| "spec/#{m[1]}_spec.rb" }
  # watch(%r{^app/(.*)(\.erb|\.haml)$})                 { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
  # watch(%r{^app/controllers/(.+)_(controller)\.rb$})  { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
  # watch(%r{^spec/support/(.+)\.rb$})                  { "spec" }
  # watch('config/routes.rb')                           { "spec/routing" }
  # watch('app/controllers/application_controller.rb')  { "spec/controllers" }
  # # Capybara request specs
  # watch(%r{^app/views/(.+)/.*\.(erb|haml)$})          { |m| "spec/requests/#{m[1]}_spec.rb" }
end

I have tried multiple version of ignore, but it still fail.

The problem is basically that the tmp folder ember use to generate the preview app make guard go crazy. And it seems the guard ignore does not really make guard avoid the folder, it still scans it.

How can I make the guard file ignore the ember folder so that I can restore rspec-guard ?

EDIT

I have edited the guardfile as following :

guard 'rspec',:cli => "--drb --format progress",all_after_pass: false do
  ignore(%r{^marketadmin/(.+)}) 
end

It still fails with the following error (there is so many errors i had to set the terminal memory to 30 000 lines, 20 000 was not enough) :

18:24:39 - INFO - Guard::RSpec is running
18:24:39 - DEBUG - Hook :start_end executed for Guard::RSpec
D, [2017-08-24T18:25:00.166155 #20128] DEBUG -- : Waiting for processing to start...
18:25:00 - INFO - Guard is now watching at '/home/sylvain/dev/placedemarche'
18:25:00 - DEBUG - Start interactor
        ** ERROR: directory is already being watched! **

        Directory: /home/sylvain/dev/placedemarche/marketadmin/tmp/funnel-input_base_path-WVhWKrYs.tmp

        is already being watched through: /home/sylvain/dev/placedemarche/marketadmin/node_modules/qunit-notifications

        MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
        ** ERROR: directory is already being watched! **

        Directory: /home/sylvain/dev/placedemarche/marketadmin/tmp/funnel-input_base_path-ULeE6XMF.tmp

        is already being watched through: /home/sylvain/dev/placedemarche/marketadmin/app

        MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
2 Answers

Guard now has a way to specify which directories to watch. If you specify only the top-level directories that you need, leaving marketadmin or the name of your ember-cli subdirectory out of the list, then it will be ignored:

  directories %w[app config lib spec features]

You may need additional directories depending on your application's setup, but the key is to exclude marketadmin.

https://github.com/guard/guard/wiki/Guardfile-DSL---Configuring-Guard#directories

Related