我有一个我一直在使用ruby 1.9.1的应用程序。我想在我的UI中测试javascript,而capybara的默认selenium驱动程序不支持我需要测试的事件。
所以我正在经历使用rvm将应用程序切换到jruby进行测试的过程,因为显然celertiy / culerity目前仅适用于jruby。我已经安装了我的软件包,应用程序似乎在jruby上正常工作,但是当我尝试运行'rake cucumber'时,我得到以下输出:
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-...]
有一次我使用sqlite作为我的测试数据库,但后来改变了。我甚至尝试过改回sqlite,但仍然得到同样的错误。如果我在features / support / env.rb中禁用了database_cleaner,那么测试会运行,但它们都会神秘地失败。
任何人都知道这里发生了什么?
答案 0 :(得分:1)
看来这是数据库清理器和jdbc交互方式的问题。
http://github.com/tmikoss/database_cleaner/commit/83d85cf7740e4aef97dd6fd5c0908cb09a2f0ca9
更新: 我找到了这个问题,因为我正在努力解决同样的问题。我上面链接的database_cleaner版本确实解决了这个问题,database_cleaner项目上存在一个问题,它也会通知团队这个问题。我暂时能够绕过它:
# 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"
更新更新: 此修复程序应该在database_cleaner master
的v0.6.0上提供答案 1 :(得分:0)
您是否检查过您使用的SQLite适配器是否与jRuby兼容?您需要以下内容:
宝石:activerecord-jdbcsqlite3-adapter
和jdbc-sqlite3
(我总是安装两者,你可能只使用activerecord-jdbcsqlite3-adapter
)
然后编辑config/database.yml
以使用jdbcsqlite3适配器:
cucumber:
adapter: jdbcsqlite3
database: db/development.sqlite3
timeout: 5000