1

単体テスト ファイルがありますtest/unit/salon_test.rb。を実行するruby -Itest test/unit/salon_test.rbと、テストは問題なくパスします。を実行しようとするとbundle exec rake test:units、次のようなエラーがいくつか発生します。

2) Error:
test_create_account(SalonTest):
NoMethodError: undefined method `params' for main:Object
    /Users/jason/Web/snip/rake/ruby/1.9.1/bundler/gems/authlogic-309187b26594/lib/authlogic/controller_adapters/abstract_adapter.rb:30:in `params'
    /Users/jason/Web/snip/rake/ruby/1.9.1/bundler/gems/authlogic-309187b26594/lib/authlogic/session/params.rb:96:in `params_credentials'
    /Users/jason/Web/snip/rake/ruby/1.9.1/bundler/gems/authlogic-309187b26594/lib/authlogic/session/params.rb:72:in `params_enabled?'
    /Users/jason/Web/snip/rake/ruby/1.9.1/bundler/gems/authlogic-309187b26594/lib/authlogic/session/params.rb:66:in `persist_by_params'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:407:in `_run__2708293592470526601__persist__999583656123085136__callbacks'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:405:in `__run_callback'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:385:in `_run_persist_callbacks'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
    /Users/jason/Web/snip/rake/ruby/1.9.1/bundler/gems/authlogic-309187b26594/lib/authlogic/session/callbacks.rb:88:in `persist'
    /Users/jason/Web/snip/rake/ruby/1.9.1/bundler/gems/authlogic-309187b26594/lib/authlogic/session/persistence.rb:55:in `persisting?'
    /Users/jason/Web/snip/rake/ruby/1.9.1/bundler/gems/authlogic-309187b26594/lib/authlogic/session/persistence.rb:39:in `find'
    /Users/jason/Web/snip/rake/ruby/1.9.1/bundler/gems/authlogic-309187b26594/lib/authlogic/acts_as_authentic/session_maintenance.rb:96:in `block in get_session_information'
    /Users/jason/Web/snip/rake/ruby/1.9.1/bundler/gems/authlogic-309187b26594/lib/authlogic/acts_as_authentic/session_maintenance.rb:95:in `each'
    /Users/jason/Web/snip/rake/ruby/1.9.1/bundler/gems/authlogic-309187b26594/lib/authlogic/acts_as_authentic/session_maintenance.rb:95:in `get_session_information'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:407:in `_run__852872703163537099__save__999583656123085136__callbacks'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:405:in `__run_callback'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/callbacks.rb:264:in `create_or_update'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/persistence.rb:84:in `save'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/validations.rb:50:in `save'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/attribute_methods/dirty.rb:22:in `save'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/transactions.rb:241:in `block (2 levels) in save'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:190:in `transaction'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/transactions.rb:208:in `transaction'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/transactions.rb:241:in `block in save'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/transactions.rb:252:in `rollback_active_record_state!'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/transactions.rb:240:in `save'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/autosave_association.rb:409:in `save_belongs_to_association'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/autosave_association.rb:209:in `block in add_autosave_association_callbacks'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/autosave_association.rb:161:in `instance_eval'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/autosave_association.rb:161:in `block in define_non_cyclic_method'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:418:in `_run__3406207238143745546__save__999583656123085136__callbacks'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:405:in `__run_callback'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/callbacks.rb:264:in `create_or_update'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/persistence.rb:84:in `save'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/validations.rb:50:in `save'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/attribute_methods/dirty.rb:22:in `save'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/transactions.rb:241:in `block (2 levels) in save'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:190:in `transaction'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/transactions.rb:208:in `transaction'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/transactions.rb:241:in `block in save'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/transactions.rb:252:in `rollback_active_record_state!'
    /Users/jason/Web/snip/rake/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/transactions.rb:240:in `save'
    /Users/jason/Web/snip/test/unit/salon_test.rb:57:in `block in <class:SalonTest>'

この同様の質問を見たことがありますが、私が知る限り、同じ問題ではないようです。

ちなみに、私は Rails 3.2.1 を使用しています。

Railsの単体テストについてはよくわかりません。問題は何ですか?

4

1 に答える 1

1

Authlogic(Deviseに置き換えました)をアンインストールすると、問題は解決しました。

于 2012-06-13T20:11:37.387 に答える