2

我有一个我一直在使用 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,测试会运行,但它们都会神秘地失败。

有人知道这里发生了什么吗?

4

2 回答 2

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 上可用

于 2010-10-25T16:59:22.537 回答
0

您是否检查过您使用的 SQLite 适配器是否与 jRuby 兼容?您需要以下内容:

宝石:activerecord-jdbcsqlite3-adapterjdbc-sqlite3

(我总是安装两个,你可能只用好activerecord-jdbcsqlite3-adapter

然后编辑config/database.yml以使用 jdbcsqlite3 适配器:

cucumber:
  adapter: jdbcsqlite3
  database: db/development.sqlite3
  timeout: 5000
于 2010-10-25T12:59:54.467 回答