2012-01-18 69 views
16

我使用Libnotify提供的通知成功運行Guard。Guard RS/RSpec2,Ruby1.9.3,Rails 3.1.3

[email protected]:~/railsprojects/sample_app$ guard 
Guard uses Libnotify to send notifications. 
Guard is now watching at '/home/funkdified/railsprojects/sample_app' 
Guard::RSpec is running, with RSpec 2! 
Running all specs 
... 

Finished in 0.06053 seconds 
3 examples, 0 failures 

如果我修改spec文件,我會收到有關測試結果的警告,包括終端和彈出通知。如果我修改了一個控制器文件,再次測試運行正常。但是,當我修改routes.rb時,整個事情都落在它的面上,Guard正常停止工作並拋出錯誤。有人有主意嗎?

錯誤:

Running: spec/routing 
/home/funkdified/.rvm/gems/[email protected]/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load': cannot load such file -- /home/funkdified/railsprojects/sample_app/spec/routing (LoadError) 
    from /home/funkdified/.rvm/gems/[email protected]/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `block in load_spec_files' 
    from /home/funkdified/.rvm/gems/[email protected]/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `map' 
    from /home/funkdified/.rvm/gems/[email protected]/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load_spec_files' 
    from /home/funkdified/.rvm/gems/[email protected]/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:22:in `run' 
    from /home/funkdified/.rvm/gems/[email protected]/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process' 
    from /home/funkdified/.rvm/gems/[email protected]/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run' 
    from /home/funkdified/.rvm/gems/[email protected]/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `block in autorun 

忘了提,如果我殺了衛隊和重啓然後再衛隊通常執行,這表明測試已經失敗(在修改的routes.rb後):

[email protected]:~/railsprojects/sample_app$ guard 
Guard uses Libnotify to send notifications. 
Guard is now watching at '/home/funkdified/railsprojects/sample_app' 
Guard::RSpec is running, with RSpec 2! 
Running all specs 
..F 

Failures: 

    1) PagesController GET 'about' returns http success 
    Failure/Error: get 'about' 
    ActionController::RoutingError: 
     No route matches {:controller=>"pages", :action=>"about"} 
    # ./spec/controllers/pages_controller_spec.rb:22:in `block (3 levels) in <top (required)>' 

Finished in 0.0576 seconds 
3 examples, 1 failure 

Failed examples: 

rspec ./spec/controllers/pages_controller_spec.rb:21 # PagesController GET 'about' returns http success 

回答

30

檢查您的spec目錄。它應該有一個routing子目錄路由規格。如果沒有,只需創建一個空的。顯然,在運行rails g rspec:install時,RSpec不會在spec下創建任何子目錄,但警衛希望它在那裏。

2

我認爲你可能有下面一行在你Guardfile

watch('config/routes.rb')       { "spec/routing" } 

如果你沒有在規格spec/routing,那就不要夾,你並不需要。行更改爲:

watch('config/routes.rb')       { "spec" } 

現在,當您更新routes.rb文件中的所有您的規格運行。