I followed the Rails Tutorial on setting up automated tests with Guard and Spork. Every once in a while, especially when saving an unedited template in my editor, Guard will complain (full backtrace):
ERROR: Problem with watch action!
undefined method `singularize' for "layouts":String
My Guardfile:
# 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 doesn't complain if I restart, but restarting is getting a bit annoying; admittedly, not as annoying as running rspec
every time I want a test.
.autotest
may be the wrong file for guard, since this isn't fixing the issue.Actually, in the Rails tutorial they're adding require 'active_support/core_ext'
at the top of the Guardfile.
I think this might fix your issue.
Also be sure to declare the spork guard before the rspec guard.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With