views:

57

answers:

2

I've got an application I've been working on with ruby 1.9.1. I'd like to test the javascript in my UI and the default selenium driver for capybara doesn't support the events I need to test.

So I'm going through the process of using rvm to switch the application on to jruby for testing, since apparently celertiy/culerity only work on jruby at the moment. I've got my bundle installed and the application seems to work correctly on jruby, but when I try to run 'rake cucumber' I get the following output:

Using the default profile...
superclass mismatch for class SQLiteAdapter (TypeError)
/home/david/.rvm/gems/jruby-1.5.3@test2/gems/database_cleaner-0.5.2/lib/database_cleaner/active_record/truncation.rb:11
/home/david/.rvm/gems/jruby-1.5.3@test2/gems/database_cleaner-0.5.2/lib/database_cleaner/active_record/truncation.rb:239:in `require'
/home/david/.rvm/gems/jruby-1.5.3@test2/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require'
/home/david/.rvm/gems/jruby-1.5.3@test2/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:227:in `load_dependency'
/home/david/.rvm/gems/jruby-1.5.3@test2/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require'
/home/david/.rvm/gems/jruby-1.5.3@test2/gems/database_cleaner-0.5.2/lib/database_cleaner/configuration.rb:86:in `orm_strategy'
/home/david/.rvm/gems/jruby-1.5.3@test2/gems/database_cleaner-0.5.2/lib/database_cleaner/configuration.rb:42:in `create_strategy'
/home/david/.rvm/gems/jruby-1.5.3@test2/gems/database_cleaner-0.5.2/lib/database_cleaner/configuration.rb:56:in `strategy='
/home/david/rental/features/support/env.rb:58
/home/david/rental/features/support/env.rb:143:in `load'
/home/david/.rvm/gems/jruby-1.5.3@test2/gems/cucumber-0.9.2/bin/../lib/cucumber/rb_support/rb_language.rb:143:in `load_code_file'
/home/david/.rvm/gems/jruby-1.5.3@test2/gems/cucumber-0.9.2/bin/../lib/cucumber/runtime/support_code.rb:158:in `load_file'
/home/david/.rvm/gems/jruby-1.5.3@test2/gems/cucumber-0.9.2/bin/../lib/cucumber/runtime/support_code.rb:61:in `load_files!'
/home/david/.rvm/gems/jruby-1.5.3@test2/gems/cucumber-0.9.2/bin/../lib/cucumber/runtime/support_code.rb:60:in `each'
/home/david/.rvm/gems/jruby-1.5.3@test2/gems/cucumber-0.9.2/bin/../lib/cucumber/runtime/support_code.rb:60:in `load_files!'
/home/david/.rvm/gems/jruby-1.5.3@test2/gems/cucumber-0.9.2/bin/../lib/cucumber/runtime.rb:185:in `load_step_definitions'
/home/david/.rvm/gems/jruby-1.5.3@test2/gems/cucumber-0.9.2/bin/../lib/cucumber/runtime.rb:26:in `run!'
/home/david/.rvm/gems/jruby-1.5.3@test2/gems/cucumber-0.9.2/bin/../lib/cucumber/cli/main.rb:54:in `execute!'
/home/david/.rvm/gems/jruby-1.5.3@test2/gems/cucumber-0.9.2/bin/../lib/cucumber/cli/main.rb:29:in `execute'
/home/david/.rvm/gems/jruby-1.5.3@test2/gems/cucumber-0.9.2/bin/cucumber:8
rake aborted!
Command failed with status (1): [bundle exec /home/david/.rvm/rubies/jruby-...]

At one point I was using sqlite for my test db, but have since changed. I've even tried changing back to sqlite, but still get the same error. If I disable database_cleaner in features/support/env.rb the tests run, but they all fail mysteriously.

Anyone know what's going on here?

A: 

Did you check that the SQLite adapter you're using is compatible with jRuby? You'd need the following:

Gems: activerecord-jdbcsqlite3-adapter and jdbc-sqlite3

(I always install both, you might be good to go with only activerecord-jdbcsqlite3-adapter)

Then edit config/database.yml to use the jdbcsqlite3 adapter:

cucumber:
  adapter: jdbcsqlite3
  database: db/development.sqlite3
  timeout: 5000
Ariejan
I'm currently using mysql, not sqlite3. I did try switching to sqlite3 to see if that would solve the issue (it did not) and I did use the jdbc adapters. Thanks for the input!
biagidp
+1  A: 

It appears this is a problem with the way that database cleaner and jdbc are interacting.

http://github.com/tmikoss/database_cleaner/commit/83d85cf7740e4aef97dd6fd5c0908cb09a2f0ca9

UPDATE: I found this question because I was struggling with the same issue. The version of database_cleaner I linked to above does indeed fix the issue, there is an issue on the database_cleaner project that notifies the team of the issue as well. I was able to get around it for the moment by:

# someplace on your computer    
git clone http://github.com/tmikoss/database_cleaner.git

#in your projects Gemfile
gem "database_cleaner", :path => "path/to/above/copy/of/gem"

UPDATE UPDATE: this fix should be available on v0.6.0 of database_cleaner master

Jed Schneider
This worked. All I had to do was specify 0.6.0 in my Gemfile and it worked like a charm. Thanks!
biagidp