active_record hook prevents features that access multiple database from running correctly #152

Confusion opened this Issue Jul 5, 2011 · 2 comments

3 participants


I have a feature that uses data from two separate database. This feature does not work when using cucumber-rails 1.0.2. The issue is that the first connection, to the regular Rails database, get stored as @@shared_connection in ActiveRecord::Base by the cucumber-rails active_record hook (lib/cucumber/rails/hooks/active_record.rb). After a connection to the second database is established, ActiveRecord::Base.connection still returns the @@shared_connection which is a connection to the wrong database.

A solution is to keep such a shared_connection per connection specification with which establish_connection has been invoked.

There are however other problems with this hook. For instance, it prevents you from writing features to test massively concurrent use of an application, by creating a bottleneck where the actual application has none.

The code was added in commit cbcfd88, but the commit message does not really explain why it was necessary.

@winnipegtransit winnipegtransit pushed a commit to winnipegtransit/cucumber-rails that referenced this issue Aug 3, 2011
Doug Hiebert Fix issue #152. 87ba8ec

I can verify that @winnipegtransit's change has fixed the issue. I guess it won't be merged until it has tests though.

@aslakhellesoy aslakhellesoy added a commit that referenced this issue Sep 12, 2011
Doug Hiebert Fix issue #152. 9e64e7c
Cucumber member

Forgot to close this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment