質問

I'm absolutely baffled.. (And quite frustrated too.. )

For some reason guard isn't detecting file updates on osx, but only for certain files. It's almost like the regexp defined in the watch function isn't working or something..

I have created a brand new rails app for fiddling around following Ryans guard railscast -- http://railscasts.com/episodes/264-guard

And have the default guardfile as generated by;

guard init spec

which looks like this;

# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard 'rspec', :cli => "--color --format nested --fail-fast" do
  watch(%r{^spec/.+_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" }

  # Turnip features and steps
  watch(%r{^spec/acceptance/(.+)\.feature$})
  watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$})   { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end

If I edit application_controller.rb or a spec file in the spec dir, guard will autorun just fine.

But if I edit and save any other controller, nothing happens.

I have run guard as both guard and bundle exec guard with no difference; It just runs the full suite once then sits there at a prompt.

macbook pro os v10.6.8.
RVM with Ruby-1.9.3-p286 and Rails 3.2.8 rb-fsevent 0.9.2

One of my coworkers is running the exact same thing directly pulled from git with the same system specs (company issued mbp's), and it works for him.

When he edits app/home_controller.rb and just gives it an extra line or something, hits save.. the tests fire.

When I edit the file and hit save, nothing happens but if I edit app/application_controller.rb it fires..

I'm confused.. I'm frustrated.. I need help as I'm at a loss..

Thoughts?

役に立ちましたか?

解決

It looks like a problem with rb-fsevent an OS X 10.6. You can try if an older version of rb-fsevent will work by setting a fixed version in your Gemfile like

gem 'rb-fsevent', '0.9.0'

or you can work around the issue by switching to polling:

bundle exec guard --force-polling

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top