16

Libnotify によって提供される通知で Guard を正常に実行しています。

funkdified@funkdified-laptop:~/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

仕様ファイルを変更すると、ターミナルとポップアップ通知の両方で、テストの結果が通知されます。コントローラ ファイルを変更すると、再びテストが正常に実行されます。しかし、routes.rb を変更すると、すべてが台無しになり、Guard が正常に動作しなくなり、エラーが発生します。誰にもアイデアはありますか?

エラー:

Running: spec/routing
/home/funkdified/.rvm/gems/ruby-1.9.3-p0@rails3tutorial/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/ruby-1.9.3-p0@rails3tutorial/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `block in load_spec_files'
    from /home/funkdified/.rvm/gems/ruby-1.9.3-p0@rails3tutorial/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `map'
    from /home/funkdified/.rvm/gems/ruby-1.9.3-p0@rails3tutorial/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load_spec_files'
    from /home/funkdified/.rvm/gems/ruby-1.9.3-p0@rails3tutorial/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:22:in `run'
    from /home/funkdified/.rvm/gems/ruby-1.9.3-p0@rails3tutorial/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process'
    from /home/funkdified/.rvm/gems/ruby-1.9.3-p0@rails3tutorial/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run'
    from /home/funkdified/.rvm/gems/ruby-1.9.3-p0@rails3tutorial/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `block in autorun

言い忘れましたが、Guard を強制終了して再起動すると (routes.rb に変更を加えた後)、Guard は再び正常に動作し、テストが失敗したことを示しています。

funkdified@funkdified-laptop:~/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
4

2 に答える 2

30

specディレクトリを確認してください。routingルーティング スペック用のサブディレクトリが必要です。そうでない場合は、空のものを作成してください。spec明らかに、RSpec は実行時にサブディレクトリを作成しませんrails g rspec:installが、guard はそこにサブディレクトリがあることを期待しています。

于 2012-03-16T01:03:39.003 に答える
2

に次の行があると思いますGuardfile

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

にスペックがない場合はspec/routing、必要のないフォルダーを作成しないでください。行を次のように変更します。

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

これで、ファイルを更新すると、すべての仕様が実行されroutes.rbます。

于 2013-04-17T14:38:29.510 に答える