Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails guard_test_runner.rb:1:在'require'中:无法加载此类文件_Ruby On Rails_Ruby_Tdd_Minitest_Guard - Fatal编程技术网

Ruby on rails guard_test_runner.rb:1:在'require'中:无法加载此类文件

Ruby on rails guard_test_runner.rb:1:在'require'中:无法加载此类文件,ruby-on-rails,ruby,tdd,minitest,guard,Ruby On Rails,Ruby,Tdd,Minitest,Guard,我正在尝试创建一个.Guardfile,使我的所有Rails项目都可以在我的用户目录中运行 .Guardfile内容概述如下: # 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')

我正在尝试创建一个.Guardfile,使我的所有Rails项目都可以在我的用户目录中运行

.Guardfile内容概述如下:

# 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
但是,当我在rails目录的根目录中运行guard时,我会遇到以下问题

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)>

有人有什么想法吗?

我在使用Rails 4的minitest时遇到了同样的问题。我补充说:

gem guard
gem guard-minitest

然后用guard init minitest生成guard文件,一切都开始正常工作。

我也有过类似的经历。问题是在我通过在终端中运行下面的代码初始化项目中的Guard gem之后开始的

bundle exec guard init
我尝试了很多解决方案来解决这个问题。比如

卸载守护宝石 卸载Guard minitest gem 正在删除项目根目录中的Guardfile 但似乎没有一个有效,因为我仍然面临着同样的问题。我所要做的就是重新创建项目,跳过了Guard gem和Guard minitest gem的安装和初始化

我猜这是一个与gem不兼容的问题

就这些

我希望这有帮助