Closed michaelklishin closed 1 year ago
same for rails-3.2.0, even master branch for github
I ran into a similar problem with MySQL when upgrading to Rails 3.2 . I was able to fix by patching the code in the installed gem (ugly I know!):
# lib/database_cleaner/active_record/truncation.rb line 177
if defined?(AbstractMysqlAdapter) && MysqlAdapter < AbstractMysqlAdapter
MYSQL_ADAPTER_PARENT = USE_ARJDBC_WORKAROUND ? JdbcAdapter : AbstractMysqlAdapter
else
MYSQL_ADAPTER_PARENT = USE_ARJDBC_WORKAROUND ? JdbcAdapter : AbstractAdapter
end
if defined?(AbstractMysqlAdapter) && Mysql2Adapter < AbstractMysqlAdapter
MYSQL2_ADAPTER_PARENT = AbstractMysqlAdapter
else
MYSQL2_ADAPTER_PARENT = AbstractAdapter
end
You may be able to pull off a similar trick for the Postgres adapter. (I just use bundle show database_cleaner
to find out where the gem is installed and then edit in place--you can also install gem_open
and then do bundle open database_cleaner
).
The trouble is that the patch above causes the specs to database_cleaner gem's specs to fail since MysqlAdapter
is not defined at this point. I don't think this approach in the code is good. If there was a way to do a class_eval
, that would get around the problem with determining the parent class. Seems like there has been quite a bit of discussion about this previously:
Hope this info sheds some light and helps you solve your issue!
I work on a web application using jruby 1.8.7 and want to use database_cleaner 1.1.1 with capybara for tests. But it fails when I execute tests and look similar to your bug :
/home/luc/.rbenv/versions/1.8.7-debian/gems/gems/database_cleaner-1.1.1/lib/database_cleaner/active_record/truncation.rb:185: uninitialized constant ActiveRecord::ConnectionAdapters::JdbcAdapter (NameError)
from /home/luc/.rbenv/versions/1.8.7-debian/gems/gems/database_cleaner-1.1.1/lib/database_cleaner/base.rb:129:in `orm_strategy'
from /home/luc/.rbenv/versions/1.8.7-debian/gems/gems/database_cleaner-1.1.1/lib/database_cleaner/base.rb:33:in `create_strategy'
from /home/luc/.rbenv/versions/1.8.7-debian/gems/gems/database_cleaner-1.1.1/lib/database_cleaner/base.rb:37:in `clean_with'
from /home/luc/.rbenv/versions/1.8.7-debian/gems/gems/database_cleaner-1.1.1/lib/database_cleaner/configuration.rb:85:in `clean_with'
from /home/luc/.rbenv/versions/1.8.7-debian/gems/gems/database_cleaner-1.1.1/lib/database_cleaner/configuration.rb:85:in `each'
from /home/luc/.rbenv/versions/1.8.7-debian/gems/gems/database_cleaner-1.1.1/lib/database_cleaner/configuration.rb:85:in `clean_with'
from /home/luc/projects/chouette2/spec/spec_helper.rb:40
This bug was fixed and it 's a new one or not?
Unfortunately this is still an issue. I've started working on the code to add jruby support but it might take a while.
If anyone is interested in helping with this, please let me know.
Closing this for now because JRuby is not supported by this gem.
Recently released 0.7.1 seems to break on JRuby (both 1.8 and 1.9 modes). Here's travis-ci.org build link.