簡體   English   中英

保護寶石-沒有這樣的文件或目錄錯誤

[英]Guard gem - no such file or directory ERROR

我目前正在閱讀Michael Hartl撰寫Ruby on Rails教程的第三章。在設置Guard的上一節中,當我嘗試運行所有測試時出現錯誤:

21:48:12 - INFO - Running: all tests
guard(main)> - No such file or directory - bin/rails test test/controllers/static_pages_controller_test.rb test/test_helper.rb

我不確定為什么會這樣,因為當我從命令行運行該rails test命令時,它會按預期工作。

GUARDFILE:

# Defines the matching rules for Guard.
guard :minitest, spring: "bin/rails test", all_on_start: false do
  watch(%r{^test/(.*)/?(.*)_test\.rb$})
  watch('test/test_helper.rb') { 'test' }
  watch('config/routes.rb')    { integration_tests }
  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
  watch(%r{app/views/users/*}) do
    resource_tests('users') +
        ['test/integration/microposts_interface_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

因此,經過一番混亂之后,我只是刪除了

spring: "bin/rails test"

在第一行。 這樣就解決了所有問題,並且測試套件現在可以自動運行。

我通過從

guard :minitest, spring: 'bin/rails test', all_on_start: false do

guard :minitest, spring: 'rake test', all_on_start: false do

我的設置導軌:5.0.1紅寶石:2.3.0p0(2015-12-25修訂版53290

閱讀這篇文章后得到啟發

我在Windows 10上,並從第二行刪除了“ bin /” 然后將如下所示:

guard :minitest, spring: "rails test", all_on_start: false do

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM