Search code examples
rubyregexguard

Configuring guard to monitor controller sub-directories


I'm new to ruby and I'm trying to configure guard to monitor controllers in a nested directory.

Here is the directory structure

/app
  /controllers
    /manage   
      /my_controller.rb

Here is the watch expression that should fire when the file my_controller.rb is edited

watch(%r{^app/controllers/(.+)/(.+)_(controller)\.rb$})  
  { |m| [
    "spec/routing/#{m[2]}_routing_spec.rb", 
    "spec/#{m[3]}s/#{m[1]}/#{m[2]}_#{m[3]}_spec.rb", 
    "spec/acceptance/#{m[2]}_spec.rb"] 
  }

Note that i don't have routing or acceptance tests, I'm just trying to modify the existing controller watch statement to work with the controller in a nested directory. Also, note that I was able to successfully watch the spec file for changes by adding the following line

watch(%r{^spec/.+/.+_spec\.rb$})

Any insight would be appreciated.


Solution

  • Well, @rainkinz had it right. There was a typo in the specfile name that I couldn't see. I used the -d switch when running guard which printed debug statements that brought the error to my attention.