我的工厂有以下内容.rb:
factory :ffsupervisor, class: Supervisor do
first_name "ffsupervisor"
email "ffsupervisor@abc.com"
password "123456"
type "Supervisor"
association :agency, name: "FFAgency", full_fee: "2.0", partial_fee: "1.0", agency_type: "Fulfilment"
end
我可以在Rails控制台中使用FactoryGirl::create(:ffsupervisor)
在我的数据库中构建和保存Supervisor实例。当我尝试在我的功能规格中做同样的事情时,我最终得到了:
NoMethodError:未定义的方法`stringify_keys'。
我在SO中就这个问题调查了很多问题。虽然没有弄清楚我错过了什么。对此有所了解会很棒。 TIA!
编辑: 这是我得到的堆栈跟踪:
1) Workflow order_item lifecycle.
Failure/Error: @supervisor= FactoryGirl::create(:ffsupervisor) # Creates both agency & supervisor.
NoMethodError:
undefined method `stringify_keys' for #<Supervisor:0x0000000baa9410>
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activemodel-4.0.0/lib/active_model/attribute_methods.rb:436:in `method_missing'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/attribute_methods.rb:131:in `method_missing'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/attribute_assignment.rb:17:in `assign_attributes'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/core.rb:192:in `initialize'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/devise-3.3.0/lib/devise/models/confirmable.rb:47:in `initialize'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/inheritance.rb:27:in `new'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/inheritance.rb:27:in `new'
# ./app/mailers/synup_mailer.rb:13:in `confirmation_instructions'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/actionpack-4.0.0/lib/abstract_controller/base.rb:189:in `process_action'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/actionpack-4.0.0/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:373:in `_run__1572042514373682743__process_action__callbacks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/actionpack-4.0.0/lib/abstract_controller/callbacks.rb:17:in `process_action'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/actionpack-4.0.0/lib/abstract_controller/base.rb:136:in `process'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/actionpack-4.0.0/lib/abstract_controller/rendering.rb:44:in `process'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/actionmailer-4.0.0/lib/action_mailer/base.rb:503:in `process'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/actionmailer-4.0.0/lib/action_mailer/base.rb:497:in `initialize'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/resque_mailer-2.2.6/lib/resque_mailer.rb:121:in `new'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/resque_mailer-2.2.6/lib/resque_mailer.rb:121:in `actual_message'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/resque_mailer-2.2.6/lib/resque_mailer.rb:97:in `initialize'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/resque_mailer-2.2.6/lib/resque_mailer.rb:40:in `new'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/resque_mailer-2.2.6/lib/resque_mailer.rb:40:in `method_missing'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/devise-3.3.0/lib/devise/models/authenticatable.rb:173:in `send_devise_notification'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/devise-3.3.0/lib/devise/models/confirmable.rb:102:in `send_confirmation_instructions'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/devise-3.3.0/lib/devise/models/confirmable.rb:158:in `send_on_create_confirmation_instructions'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:397:in `_run__462299154380556768__create__callbacks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/callbacks.rb:303:in `create_record'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/timestamp.rb:57:in `create_record'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/persistence.rb:466:in `create_or_update'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/callbacks.rb:299:in `block in create_or_update'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:393:in `_run__462299154380556768__save__callbacks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/callbacks.rb:299:in `create_or_update'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/persistence.rb:128:in `save!'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/validations.rb:57:in `save!'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/attribute_methods/dirty.rb:41:in `save!'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/transactions.rb:275:in `block in save!'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/transactions.rb:326:in `block in with_transaction_returning_status'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/ar_after_transaction-0.4.0/lib/ar_after_transaction.rb:19:in `block in transaction_with_after'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `transaction'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/transactions.rb:209:in `transaction'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/ar_after_transaction-0.4.0/lib/ar_after_transaction.rb:17:in `transaction_with_after'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/transactions.rb:323:in `with_transaction_returning_status'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.0/lib/active_record/transactions.rb:275:in `save!'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/configuration.rb:14:in `block in initialize'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/evaluation.rb:15:in `[]'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/evaluation.rb:15:in `create'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/strategy/create.rb:12:in `block in result'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/strategy/create.rb:9:in `tap'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/strategy/create.rb:9:in `result'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/factory.rb:42:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/factory_runner.rb:23:in `block in run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.0/lib/active_support/notifications.rb:161:in `instrument'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/factory_runner.rb:22:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/factory_girl-4.2.0/lib/factory_girl/strategy_syntax_method_registrar.rb:19:in `block in define_singular_strategy_method'
# ./spec/features/workflow_spec.rb:39:in `block (2 levels) in <top (required)>'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:114:in `instance_eval'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:114:in `block in run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:179:in `call'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:179:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_exec'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_eval_with_args'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:247:in `instance_eval_with_args'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/hooks.rb:87:in `block (2 levels) in run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/hooks.rb:89:in `call'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/hooks.rb:89:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/hooks.rb:418:in `run_hook'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:329:in `run_around_each_hooks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:256:in `with_around_each_hooks'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:111:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:390:in `block in run_examples'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:386:in `map'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:386:in `run_examples'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:371:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:28:in `map'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:28:in `block in run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/reporter.rb:34:in `report'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:25:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
# /home/ananth/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'