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 回答