所以我试图将guard rspec 仅用于ruby,而不是用于rails。测试运行良好,但唯一的问题是它只查找 spec.rb 文件,而不查找实际文件。所以我有一个失败的arabic_to_roman.rb 和arabic_to_roman_spec.rb。Guardfile 安装在 roman_numerals_kata 目录下。它只查找 _spec.rb 文件而不是 arabic_to_roman.rb。这是 Guardfile 的样子
1 # A sample Guardfile
2 # More info at https://github.com/guard/guard#readme
3
4 guard 'rspec' do
5 watch(%r{^spec/.+_spec\.rb$})
6 watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7 watch('spec/spec_helper.rb') { "spec" }
8
9 # Rails example
10 watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11 watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}# {m[2]}_spec.rb" }
12 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"] }
13 watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14 watch('config/routes.rb') { "spec/routing" }
15 watch('app/controllers/application_controller.rb') { "spec/controllers" }
16
17 # Capybara features specs
18 watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
19
20 # Turnip features and steps
21 watch(%r{^spec/acceptance/(.+)\.feature$})
22 watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
23 end
24