0

ruby on rails プロジェクト [1] で多くの rake テストが失敗し、すべて同じエラー (nil を String に変換できない) があり、なぜこれが起こっているのか、どのようにデバッグすればよいのかわかりません。 .

たとえば、これは rake テストの最初のトレースバックです (メッセージの最後に完全な rake テストのトレースバックを添付しました [2])。

Error:
test_update(Admin::BazarDistrictsControllerTest):
TypeError: can't convert nil into String
    /usr/lib/ruby/1.9.1/psych.rb:154:in `parse'
    /usr/lib/ruby/1.9.1/psych.rb:154:in `parse_stream'
    /usr/lib/ruby/1.9.1/psych.rb:125:in `parse'
    /usr/lib/ruby/1.9.1/psych.rb:112:in `load' 
    /srv/www/gamersmafia/current/app/models/users_skill.rb:178:in `role_data_yaml'
    /srv/www/gamersmafia/current/app/models/alert.rb:200:in `block in update_pending_alerts'
    /srv/www/gamersmafia/current/app/models/alert.rb:198:in `each'
    /srv/www/gamersmafia/current/app/models/alert.rb:198:in `update_pending_alerts'
    /usr/lib/ruby/gems/1.9.1/gems/delayed_job-3.0.5/lib/delayed/performable_method.rb:26:in `perform'
    /usr/lib/ruby/gems/1.9.1/gems/delayed_job-3.0.5/lib/delayed/backend/base.rb:95:in `block in invoke_job'
    /usr/lib/ruby/gems/1.9.1/gems/delayed_job-3.0.5/lib/delayed/lifecycle.rb:60:in `call'
    /usr/lib/ruby/gems/1.9.1/gems/delayed_job-3.0.5/lib/delayed/lifecycle.rb:60:in `block in initialize'
    /usr/lib/ruby/gems/1.9.1/gems/delayed_job-3.0.5/lib/delayed/lifecycle.rb:65:in `call'
    /usr/lib/ruby/gems/1.9.1/gems/delayed_job-3.0.5/lib/delayed/lifecycle.rb:65:in `execute'
    /usr/lib/ruby/gems/1.9.1/gems/delayed_job-3.0.5/lib/delayed/lifecycle.rb:38:in `run_callbacks'
    /usr/lib/ruby/gems/1.9.1/gems/delayed_job-3.0.5/lib/delayed/backend/base.rb:92:in `invoke_job'
    /usr/lib/ruby/gems/1.9.1/gems/delayed_job-3.0.5/lib/delayed/backend/base.rb:37:in `block in enqueue'
    /usr/lib/ruby/gems/1.9.1/gems/delayed_job-3.0.5/lib/delayed/backend/base.rb:36:in `tap'
    /usr/lib/ruby/gems/1.9.1/gems/delayed_job-3.0.5/lib/delayed/backend/base.rb:36:in `enqueue'
    /usr/lib/ruby/gems/1.9.1/gems/delayed_job-3.0.5/lib/delayed/message_sending.rb:13:in `method_missing'
    /srv/www/gamersmafia/current/app/models/alert.rb:182:in `block in update_pending_alerts'
    /srv/www/gamersmafia/current/app/models/alert.rb:180:in `each'
    /srv/www/gamersmafia/current/app/models/alert.rb:180:in `update_pending_alerts'
    /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:460:in `_run__1673722312823048322__save__808729243992924512__callbacks'
    /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `__run_callback'
    /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
    /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:81:in `run_callbacks'
    /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.12/lib/active_record/callbacks.rb:264:in `create_or_update'
    /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.12/lib/active_record/persistence.rb:84:in `save'
    /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.12/lib/active_record/validations.rb:50:in `save'
    /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.12/lib/active_record/attribute_methods/dirty.rb:22:in `save'
    /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.12/lib/active_record/transactions.rb:259:in `block (2 levels) in save'
    /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.12/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'
    /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
    /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.12/lib/active_record/transactions.rb:208:in `transaction'
    /usr/lib/ruby/gems/1.9.1/gems/deadlock_retry-1.2.0/lib/deadlock_retry.rb:31:in `transaction_with_deadlock_handling'
    /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.12/lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
    /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.12/lib/active_record/transactions.rb:259:in `block in save'
    /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.12/lib/active_record/transactions.rb:270:in `rollback_active_record_state!'
    /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.12/lib/active_record/transactions.rb:258:in `save'
    /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.12/lib/active_record/persistence.rb:45:in `create'
    /srv/www/gamersmafia/current/app/models/bazar_district.rb:158:in `update_single_person_staff'
    /srv/www/gamersmafia/current/app/models/bazar_district.rb:83:in `update_don'
    /srv/www/gamersmafia/current/app/controllers/admin/bazar_districts_controller.rb:43:in `update'
    /usr/lib/ruby/gems/1.9.1/gems/actionpack-3.2.12/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
    /usr/lib/ruby/gems/1.9.1/gems/actionpack-3.2.12/lib/abstract_controller/base.rb:167:in `process_action'
    /usr/lib/ruby/gems/1.9.1/gems/actionpack-3.2.12/lib/action_controller/metal/rendering.rb:10:in `process_action'
    /usr/lib/ruby/gems/1.9.1/gems/actionpack-3.2.12/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
    /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:503:in `block in _run__1141341086633682237__process_action__2809844012775858444__callbacks'
    /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_5310'
    /srv/www/gamersmafia/current/app/controllers/application_controller.rb:233:in `block (2 levels) in gm_process'
    /srv/www/gamersmafia/current/app/controllers/application_controller.rb:232:in `catch'
    /srv/www/gamersmafia/current/app/controllers/application_controller.rb:232:in `block in gm_process'
    /usr/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
    /srv/www/gamersmafia/current/app/controllers/application_controller.rb:231:in `gm_process'
    /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:214:in `_conditional_callback_around_5310'
    /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:469:in `_run__1141341086633682237__process_action__2809844012775858444__callbacks'
    /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `__run_callback'
    /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
    /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:81:in `run_callbacks'
    /usr/lib/ruby/gems/1.9.1/gems/actionpack-3.2.12/lib/abstract_controller/callbacks.rb:17:in `process_action'
    /usr/lib/ruby/gems/1.9.1/gems/actionpack-3.2.12/lib/action_controller/metal/rescue.rb:29:in `process_action'
    /usr/lib/ruby/gems/1.9.1/gems/actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
    /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/notifications.rb:123:in `block in instrument'
    /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/notifications.rb:123:in `instrument'
    /usr/lib/ruby/gems/1.9.1/gems/actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
    /usr/lib/ruby/gems/1.9.1/gems/actionpack-3.2.12/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
    /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.12/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
    /usr/lib/ruby/gems/1.9.1/gems/actionpack-3.2.12/lib/abstract_controller/base.rb:121:in `process'
    /usr/lib/ruby/gems/1.9.1/gems/actionpack-3.2.12/lib/abstract_controller/rendering.rb:45:in `process'
    /usr/lib/ruby/gems/1.9.1/gems/actionpack-3.2.12/lib/action_controller/metal/testing.rb:17:in `process_with_new_base_test'
    /usr/lib/ruby/gems/1.9.1/gems/actionpack-3.2.12/lib/action_controller/test_case.rb:473:in `process'
    /usr/lib/ruby/gems/1.9.1/gems/actionpack-3.2.12/lib/action_controller/test_case.rb:49:in `process'
    /usr/lib/ruby/gems/1.9.1/gems/actionpack-3.2.12/lib/action_controller/test_case.rb:395:in `post'
    /srv/www/gamersmafia/current/test/functional/admin/bazar_districts_controller_test.rb:42:in `block in <class:BazarDistrictsControllerTest>'

そして、合計1448回のテストのエラーを含む200回以上のテストがあります。

問題は、どこからデバッグを開始する必要があるかということです。+90% のテストで同じエラーが発生するのはなぜですか?

[1] https://github.com/gamersmafia/gamersmafia

[2] https://dl.dropbox.com/u/42306424/salida_rake.txt

4

2 に答える 2

0

デバッグの場合。gem 'pry-rails' の使用をお勧めします。この gem をバンドルして、失敗したテストに「binding.pry」を追加するだけです。テストのすべての変数でコンソールが開くので、手動で確認できます。何が問題なのかを知るのに役立つことを願っています。

于 2013-03-28T13:23:25.227 に答える
-1

Cucumber バージョンの問題の 1 つかもしれません。

これは、cucumber-rails を最新バージョンにアップグレードすることで修正できます。これを表示するには、Gemfile を編集するだけです。

gem 'cucumber-rails', '>= 1.1.1'または新しいバージョン

私が同じを得たとき、それは私のエラーを解決しました。

あなたの場合、その指摘delayed_job gem

使用している場合はbundler、スクリプトまたは rake タスクの前に " bundle exec"を付けてみてください。

bundle exec script/delayed_job -n 2 start 

そして試してみてください!!!!

于 2013-03-28T12:22:25.233 に答える