Guard Ruby On Rails 3.2教程 [英] Guard Ruby On Rails 3.2 Tutorial

查看:107
本文介绍了Guard Ruby On Rails 3.2教程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在跟 Ruby on Rails教程.

一切正常,但是我注意到Guard仅在保存一些文件(视图或控制器文件)后运行,而在保存其他文件(路由或规格文件)时不运行.我已经让Guard迷上了Spork,不确定这是否重要.

Things are working pretty well, but I noticed that Guard only runs after I save some files (view or controller files), but doesn't run when I save others (routes or spec files). I've got Guard hooked up to Spork, not sure if that matters.

当我查看运行Guard/Spork的控制台窗口时,在保存非运行测试后发现一个错误:

When I looked at the console window running Guard/Spork, I noticed an error after I saved the non-running tests:

Exception encountered: #<LoadError: no such file to load -- /Users/Tyler/Development/FirstRails/sample_app/spec/routing

我不确定Guard文件的语法是什么,我只是复制了示例.这是Guard文件:

I'm not sure what the syntax of the Guard file is, I just copied the example. Here is the Guard file:

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

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

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

  # Rails example
  watch(%r{^spec/.+_spec\.rb$})
  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{^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/acceptance/#    {m[1]}_spec.rb"] }
  watch(%r{^spec/support/(.+)\.rb$})                  { "spec" }
  watch('spec/spec_helper.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

guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
  watch('config/application.rb')
  watch('config/environment.rb')
  watch(%r{^config/environments/.+\.rb$})
  watch(%r{^config/initializers/.+\.rb$})
  watch('Gemfile')
  watch('Gemfile.lock')
  watch('spec/spec_helper.rb')
  watch('test/test_helper.rb')
end

特别是我的修改:

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

我没有spec/routing文件夹.

I do not have a spec/routing folder.

有人看到一个简单的错字吗?还是我需要考虑其他一些问题?

Anybody see a simple typo? Or is there some other consideration I need to have?

我在3.2轨道上

谢谢

推荐答案

找到了它:

 ["spec/routing/#{m[1]}_routing}spec.rb",

注意routingspec

现在显示:

 ["spec/routing/#{m[1]}_routing_spec.rb",

还解释了缺少的目录shananigans.

Also explains the missing directory shananigans.

谢谢!

这篇关于Guard Ruby On Rails 3.2教程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆