I am attempting to have a .Guardfile that all of my Rails projects can run off in my user directory.
The .Guardfile contents is outlined below:
# Defines the matching rules for Guard.
guard :test, all_on_start: false do
watch(%r{^test/(.*)/?(.*)_test\.rb$})
watch('test/test_helper.rb') { 'test' }
watch('config/routes.rb') { 'test' }
watch(%r{^app/models/(.*?)\.rb$}) do |matches|
"test/models/#{matches[1]}_test.rb"
end
watch(%r{^app/controllers/(.*?)_controller\.rb$}) do |matches|
resource_tests(matches[1])
end
watch(%r{^app/views/([^/]*?)/.*\.html\.erb$}) do |matches|
["test/controllers/#{matches[1]}_controller_test.rb"] +
integration_tests(matches[1])
end
watch(%r{^app/helpers/(.*?)_helper\.rb$}) do |matches|
integration_tests(matches[1])
end
watch('app/views/layouts/application.html.erb') do
'test/integration/site_layout_test.rb'
end
watch('app/helpers/sessions_helper.rb') do
integration_tests << 'test/helpers/sessions_helper_test.rb'
end
watch('app/controllers/sessions_controller.rb') do
['test/controllers/sessions_controller_test.rb',
'test/integration/users_login_test.rb']
end
watch('app/controllers/account_activations_controller.rb') do
'test/integration/users_signup_test.rb'
end
end
# Returns the integration tests corresponding to the given resource.
def integration_tests(resource = :all)
if resource == :all
Dir["test/integration/*"]
else
Dir["test/integration/#{resource}_*.rb"]
end
end
# Returns the controller tests corresponding to the given resource.
def controller_test(resource)
"test/controllers/#{resource}_controller_test.rb"
end
# Returns all tests for the given resource.
def resource_tests(resource)
integration_tests(resource) << controller_test(resource)
end
However when I run guard in the root of my rails directory I get the following issue..
11:53:04 - INFO - Guard::Test 2.0.6 is running, with Test::Unit 3.1.3!
11:53:04 - INFO - Guard is now watching at '/../../Documents/Projects/..'
[1] guard(main)>
11:53:06 - INFO - Run all
11:53:06 - INFO - Running all tests
/*/*/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/guard-test-2.0.6/lib/guard/test/guard_test_runner.rb:1:in `require': cannot load such file -- test/unit/ui/console/testrunner (LoadError)
from /../../.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/guard-test-2.0.6/lib/guard/test/guard_test_runner.rb:1:in `<top (required)>'
from -e:1:in `require'
[1] guard(main)>
Has anybody got any ideas?
I ran into the same issue using minitest with Rails 4. I added:
gem guard
gem guard-minitest
To my Gemfile
and then generated the guard file with guard init minitest
and everything started working correctly.
I had a similar experience as well. The issue began after I initialized the Guard gem in my project by running the code below in my terminal
bundle exec guard init
I tried a lot of solutions to fix the issue. Such as
But none seemed to work, as I was still facing the same issue. All I had to do was to recreate the project, and skipped the installation and initialization of the Guard gem and the Guard-minitest gem.
I guess there was an incompatibility issue with the gem.
That's all.
I hope this helps
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.