后卫不会对更改的文件轨道运行测试4.1.2

时间:2014-08-31 15:36:05

标签: ruby ruby-on-rails-4 rspec-rails guard

对于Zeus使用guard 2.6.1,guard不会对任何已更改的文件执行规范。

我正在使用带有rails 4.1.2和ruby 2.1.2的mac os x 10.9.4

当我对规范进行任何更改时,警卫立即执行,但在任何其他文件中,警卫似乎忽略了任何更改。

我的包是:

    Using capybara (2.4.1)
    Using guard (2.6.1)
    Using guard-rspec (4.3.1)
    Using guard-zeus (2.0.0)
    Using pry (0.10.1)
    Using rails (4.1.2)
    Using rb-fsevent (0.9.4)
    Using rb-inotify (0.9.5)
    Using rspec (3.0.0)
    Using rspec-core (3.0.4)
    Using rspec-expectations (3.0.4)
    Using rspec-mocks (3.0.4)
    Using rspec-rails (3.0.2)
    Using rspec-support (3.0.4)
    Using terminal-notifier-guard (1.5.3)
    Using zeus (0.15.1)

我的 Guardfile 是:

    guard :rspec, cmd: 'zeus rspec' 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|\.slim)$})          { |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" }
      watch('spec/rails_helper.rb')                       { "spec" }

      # Capybara features specs
      watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$})     { |m| "spec/features/#{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

    guard 'zeus' do
      # uses the .rspec file
      # --colour --fail-fast --format documentation --tag ~slow
      watch(%r{^spec/.+_spec\.rb$})
      watch(%r{^app/(.+)\.rb$})                           { |m| "spec/#{m[1]}_spec.rb" }
      watch(%r{^app/(.+)\.haml$})                         { |m| "spec/#{m[1]}.haml_spec.rb" }
      watch(%r{^lib/(.+)\.rb$})                           { |m| "spec/lib/#{m[1]}_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/requests/#{m[1]}_spec.rb"] }

      # TestUnit
      # watch(%r|^test/(.*)_test\.rb$|)
      # watch(%r|^lib/(.*)([^/]+)\.rb$|)     { |m| "test/#{m[1]}test_#{m[2]}.rb" }
      # watch(%r|^test/test_helper\.rb$|)    { "test" }
      # watch(%r|^app/controllers/(.*)\.rb$|) { |m| "test/functional/#{m[1]}_test.rb" }
      # watch(%r|^app/models/(.*)\.rb$|)      { |m| "test/unit/#{m[1]}_test.rb" }
    end

2 个答案:

答案 0 :(得分:1)

此Wiki条目完全用于调试文件更改不会触发操作的问题:https://github.com/guard/guard/wiki/Understanding-Guard

答案 1 :(得分:0)

Zeus需要guard中自己的Guardfile块。

$ guard init zeus

guard 'zeus' do
  # uses the .rspec file
  # --colour --fail-fast --format documentation --tag ~slow
  watch(%r{^spec/.+_spec\.rb$})
  watch(%r{^app/(.+)\.rb$})                           { |m| "spec/#{m[1]}_spec.rb" }
  watch(%r{^app/(.+)\.haml$})                         { |m| "spec/#{m[1]}.haml_spec.rb" }
  watch(%r{^lib/(.+)\.rb$})                           { |m| "spec/lib/#{m[1]}_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/requests/#{m[1]}_spec.rb"] }
  # ...
end