我刚刚将我的应用程序从Rails 4.2.0升级到4.2.5,然后突然 所有 我的测试(好,292中的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&gt; = 4.2.3。
中Rails版本(以及它使用的宝石)是我对我的存储库进行的唯一更改,一切都运行良好,直到我做到了。有谁知道为什么会这样?
答案 0 :(得分:4)
我猜它与this change to the test_after_commit gem有关。尝试将test_after_commit
更新到最新版本(0.4.2)。