2017-01-13 49 views
1

我目前正在讀Ruby on Rails Tutorial by Michael Hartl的。在最後一節,我們設立警戒我得到一個錯誤,當我嘗試運行所有測試第三章:衛隊寶石 - 沒有這樣的文件或目錄錯誤

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 
+0

我們需要看到代碼,你必須能夠找到任何問題。或者是書中失敗的代碼? – OneNeptune

+0

@OneNeptune是的,代碼與書中的代碼相同。 –

+0

請將您的'Guardfile'添加到問題 – thesecretmaster

回答

1

所以後搞亂的周圍很多,我只是在第一行刪除

spring: "bin/rails test" 

。這固定了一切,測試套件現在自動運行。

+0

是的,這可行,但爲什麼? –

1

我把它從

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

閱讀後得到靈感this post

0

我在Windows 10上並從我的第二行刪除「bin /」。它會看起來像這樣:

guard :minitest, spring: "rails test", all_on_start: false do 
相關問題