There is a problem while running cucumber features (originally started in cucumber issues). Sometimes ActiveRecord raised nil.collect!.
This problem began after we upgrading from ruby enterprise to 1.9 (currently using 1.9.3-p362). It raised only in test environment, in production and development we don't see it ever.
In all environments used PostgreSQL.
Backtrace chunk from one of the raises:
And I have new user order with line items # features/step_definitions/orders_steps.rb:1
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.collect! (NoMethodError)
/home/ssherif/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.19/lib/active_record/associations/association_collection.rb:70:in `block in find'
It's hard to understand what going wrong, but I doubt for query.cache.rb and #cache_sql method, where it's quite possible return nil result instead of Array.
This problem is very similar to #5471.
We need a way to reproduce this, there's almost no way to tell why this error is happening. Can you upload an application that reproduces this, please?
@pixeltrix very seems.
We used capybara-webkit as a default driver and database cleaner with transaction strategy.
Now I try to change cleaning strategy to truncation like recommended in cucumber/cucumber-rails#166#issuecomment-2156610
As I understood the problem more of a feature of running capybara with rails transactions than a bag?
I think the problem stems from trying to share the database connection amongst two threads - does it work correctly now?
I write about results after 2-3 days testing
Finally my problem is fixed after changing database_cleaner strategy to :truncation and setting ActiveRecord::Base.shared_connection = nil in cucumber before hook.
ActiveRecord::Base.shared_connection = nil