gpt4 book ai didi

ruby-on-rails-4 - 将 Rails 升级到 4.2.3+ 后,FactoryGirl 导致 NoMethodError

转载 作者:行者123 更新时间:2023-12-01 00:46:32 24 4
gpt4 key购买 nike

我刚刚将我的应用程序从 Rails 4.2.0 升级到 4.2.5,突然 全部 我的测试(好吧,307 个中的 292 个)失败,并显示如下消息:

 Failure/Error: let(:org)     { create :organisation }
NoMethodError:
undefined method `[]=' for nil:NilClass
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/test_after_commit-0.4.0/lib/test_after_commit.rb:57:in `sync_with_transaction_state'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/activerecord-4.2.5/lib/active_record/persistence.rb:86:in `new_record?'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:432:in `block in make_lambda'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:227:in `call'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:227:in `block (2 levels) in halting_and_conditional'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:227:in `each'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:227:in `all?'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:227:in `block in halting_and_conditional'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:506:in `call'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:506:in `block in call'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:506:in `each'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:506:in `call'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:92:in `__run_callbacks__'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:778:in `_run_initialize_callbacks'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/activerecord-4.2.5/lib/active_record/core.rb:284:in `initialize'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/activerecord-4.2.5/lib/active_record/inheritance.rb:61:in `new'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/activerecord-4.2.5/lib/active_record/inheritance.rb:61:in `new'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/factory_girl-4.5.0/lib/factory_girl/decorator/new_constructor.rb:9:in `new'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/factory_girl-4.5.0/lib/factory_girl/decorator.rb:14:in `send'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/factory_girl-4.5.0/lib/factory_girl/decorator.rb:10:in `method_missing'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/factory_girl-4.5.0/lib/factory_girl/decorator/invocation_tracker.rb:11:in `method_missing'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/factory_girl-4.5.0/lib/factory_girl/decorator.rb:14:in `send'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/factory_girl-4.5.0/lib/factory_girl/decorator.rb:10:in `method_missing'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/factory_girl-4.5.0/lib/factory_girl/configuration.rb:15:in `block in initialize'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/factory_girl-4.5.0/lib/factory_girl/attribute_assigner.rb:48:in `instance_exec'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/factory_girl-4.5.0/lib/factory_girl/attribute_assigner.rb:48:in `build_class_instance'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/factory_girl-4.5.0/lib/factory_girl/attribute_assigner.rb:13:in `object'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/factory_girl-4.5.0/lib/factory_girl/evaluation.rb:12:in `object'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/factory_girl-4.5.0/lib/factory_girl/strategy/create.rb:9:in `result'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/factory_girl-4.5.0/lib/factory_girl/factory.rb:42:in `run'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/factory_girl-4.5.0/lib/factory_girl/factory_runner.rb:23:in `block in run'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/activesupport-4.2.5/lib/active_support/notifications.rb:166:in `instrument'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/factory_girl-4.5.0/lib/factory_girl/factory_runner.rb:22:in `run'
# /home/patrick/.rvm/gems/ruby-2.1.4@engagement-hub-rails/gems/factory_girl-4.5.0/lib/factory_girl/strategy_syntax_method_registrar.rb:20:in `block in define_singular_strategy_method'
# ./spec/controllers/api/v1/channels_controller_spec.rb:11:in `block (3 levels) in <top (required)>'
# ./spec/controllers/api/v1/channels_controller_spec.rb:12:in `block (3 levels) in <top (required)>'
# ./spec/controllers/api/v1/channels_controller_spec.rb:22:in `block (3 levels) in <top (required)>'

如您所见,我使用的是 Ruby 2.1.4、Rails 4.2.5、FactoryGirl 4.5.0 和 RSpec 3.3.0。我一直在玩这些版本 - Ruby 2.2.2 没有帮助,FactoryGirl 和 RSpec 已经是最新的;并且错误发生在 Rails >= 4.2.3 中。

Rails 版本(以及它使用的 gem)是我对我的存储库所做的唯一更改,在我这样做之前,一切都运行良好。有谁知道为什么会这样?

最佳答案

我猜它与 this change to the test_after_commit gem 有关.尝试更新 test_after_commit到最新版本 (0.4.2)。

关于ruby-on-rails-4 - 将 Rails 升级到 4.2.3+ 后,FactoryGirl 导致 NoMethodError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34032538/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com