gpt4 book ai didi

ruby-on-rails - 运行 Guard 进程时出错 : can't find singularize method

转载 作者:行者123 更新时间:2023-12-03 12:10:30 24 4
gpt4 key购买 nike

我关注了Rails Tutorial关于使用 Guard and Spork 设置自动化测试.每隔一段时间,尤其是当在我的编辑器中保存未经编辑的模板 , Guard 会提示 (full backtrace):

ERROR: Problem with watch action!
undefined method `singularize' for "layouts":String

我的保护文件:
# 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" }

# 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$}) 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].singularize}_pages_spec.rb"] ### Look here ###
end
watch(%r{^app/views/(.+)/}) do |m|
"spec/requests/#{m[1].singularize}_pages_spec.rb" ### Look here ###
end
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', :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

如果我重新启动,Guard 不会提示,但是重新启动有点烦人;诚然,不像运行 rspec 那样烦人每次我想考试。
  • 我尝试了 this post 中的建议, 但我认为 .autotest可能是守卫的错误文件,因为这不能解决问题。
  • only similar error我发现与谷歌似乎不相关。
  • 最佳答案

    实际上,in the Rails tutorial他们正在添加 require 'active_support/core_ext'在 Guardfile 的顶部。

    我认为这可能会解决您的问题。

    还要确保在 rspec 保护之前声明 spork 保护。

    关于ruby-on-rails - 运行 Guard 进程时出错 : can't find singularize method,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9711239/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com