errors running rspec tests on 4.0.1.rc4

Hello,

I have some tests that run fine with rails 4.0 which use factory_girl and rspec and they fail using Rails 4.0.1.rc4

My rspec and factory_girl gems are up to date and the problem only appears once I get on rc4 rails.

Has anybody else had issues running there specs using factory girl on the latest release candidate? Any pointers or gotchas that I might be missing?

Here’s my stacktrace if it helps:

Failure/Error: user = FactoryGirl.create(:user)

NoMethodError:
undefined method `[]’ for nil:NilClass

/home/user/.gem/ruby/2.0.0/gems/activerecord-4.0.1.rc4/lib/active_record/attribute_methods/read.rb:86:in `block in read_attribute’

/home/user/.gem/ruby/2.0.0/gems/activerecord-4.0.1.rc4/lib/active_record/attribute_methods/read.rb:84:in `fetch’

/home/user/.gem/ruby/2.0.0/gems/activerecord-4.0.1.rc4/lib/active_record/attribute_methods/read.rb:84:in `read_attribute’

/home/user/.gem/ruby/2.0.0/gems/activerecord-4.0.1.rc4/lib/active_record/attribute_methods/read.rb:59:in `__temp__9646’

/home/user/.gem/ruby/2.0.0/gems/activerecord-4.0.1.rc4/lib/active_record/transactions.rb:341:in `remember_transaction_record_state’

/home/user/.gem/ruby/2.0.0/gems/activerecord-4.0.1.rc4/lib/active_record/transactions.rb:311:in `add_to_transaction’

/home/user/.gem/ruby/2.0.0/gems/activerecord-4.0.1.rc4/lib/active_record/transactions.rb:324:in `block in with_transaction_returning_status’

/home/user/.gem/ruby/2.0.0/gems/activerecord-4.0.1.rc4/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction’

/home/user/.gem/ruby/2.0.0/gems/activerecord-4.0.1.rc4/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction’

/home/user/.gem/ruby/2.0.0/gems/activerecord-4.0.1.rc4/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `transaction’

/home/user/.gem/ruby/2.0.0/gems/activerecord-4.0.1.rc4/lib/active_record/transactions.rb:209:in `transaction’

/home/user/.gem/ruby/2.0.0/gems/activerecord-4.0.1.rc4/lib/active_record/transactions.rb:323:in `with_transaction_returning_status’

/home/user/.gem/ruby/2.0.0/gems/activerecord-4.0.1.rc4/lib/active_record/transactions.rb:275:in `save!’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/configuration.rb:14:in `block in initialize’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/evaluation.rb:15:in `[]’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/evaluation.rb:15:in `create’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/strategy/create.rb:12:in `block in result’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/strategy/create.rb:9:in `tap’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/strategy/create.rb:9:in `result’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/factory.rb:42:in `run’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/factory_runner.rb:23:in `block in run’

/home/user/.gem/ruby/2.0.0/gems/activesupport-4.0.1.rc4/lib/active_support/notifications.rb:161:in `instrument’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/factory_runner.rb:22:in `run’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/strategy/create.rb:5:in `association’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/evaluator.rb:31:in `association’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/attribute/association.rb:19:in `block in to_proc’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/evaluator.rb:71:in `instance_exec’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/evaluator.rb:71:in `block in define_attribute’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/attribute_assigner.rb:56:in `get’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/attribute_assigner.rb:16:in `block (2 levels) in object’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/attribute_assigner.rb:15:in `each’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/attribute_assigner.rb:15:in `block in object’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/attribute_assigner.rb:14:in `tap’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/attribute_assigner.rb:14:in `object’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/evaluation.rb:12:in `object’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/strategy/create.rb:9:in `result’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/factory.rb:42:in `run’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/factory_runner.rb:23:in `block in run’

/home/user/.gem/ruby/2.0.0/gems/activesupport-4.0.1.rc4/lib/active_support/notifications.rb:161:in `instrument’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/factory_runner.rb:22:in `run’

/home/user/.gem/ruby/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/strategy_syntax_method_registrar.rb:19:in `block in define_singular_strategy_method’

./spec/controllers/secure_files_controller_spec.rb:5:in `block (2 levels) in <top (required)>’

Are you using protected_attributes gem?

Yes I am. I see now that I have 1.0.3 installed. I assume I need 1.0.4 to get going again here.

Yes. 1.0.3 has a know issue with Rails 4.0.1 that was fixed on 1.0.4

Just installed 1.0.4 and I’m back in business. Thanks for the heads up and help!

No problem. Thank you for testing the rc and reporting back.