2012-01-18 29 views
16

Tôi đang chạy Cảnh sát thành công với các thông báo do Libnotify cung cấp.Bảo vệ w/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 

Nếu tôi sửa đổi tệp thông số, tôi được cảnh báo về kết quả kiểm tra, cả trong thiết bị đầu cuối và thông báo bật lên. Nếu tôi sửa đổi một tập tin điều khiển, một lần nữa kiểm tra chạy bình thường. Tuy nhiên, khi tôi sửa đổi routes.rb, toàn bộ mọi thứ rơi trên khuôn mặt của nó và Guard ngừng hoạt động bình thường và ném lên một lỗi. Ai có ý tưởng gì không?

Lỗi:

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 

Quên đề cập đến, nếu tôi giết Guard và khởi động lại (sau khi thực hiện những thay đổi để routes.rb) sau đó Guard một lần nữa thực hiện bình thường, cho thấy rằng một thử nghiệm hiện nay đã thất bại:

[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 

Trả lời

30

Kiểm tra thư mục spec của bạn. Nó phải có một thư mục con routing để định tuyến thông số kỹ thuật. Nếu không, chỉ cần tạo một sản phẩm nào. Rõ ràng, RSpec không tạo ra bất kỳ thư mục con nào dưới spec khi chạy rails g rspec:install, nhưng bảo vệ hy vọng nó sẽ ở đó.

2

Tôi nghĩ rằng bạn có thể có những dòng sau trong Guardfile của bạn:

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

Nếu bạn không có thông số kỹ thuật trong spec/routing, thì đừng thư mục mà bạn không cần. Thay đổi dòng thành:

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

Bây giờ, tất cả thông số kỹ thuật của bạn sẽ chạy khi bạn cập nhật tệp routes.rb.

Các vấn đề liên quan