【问题标题】:Running integration tests with Cucumber/capybara/celerity on a Jruby on Rails application using mysql使用 mysql 在 Jruby on Rails 应用程序上使用 Cucumber/capybara/celerity 运行集成测试
【发布时间】:2010-10-26 02:50:36
【问题描述】:

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

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

【问题讨论】:

  • Rails 3.0.0 与 Ruby 1.9.1 不兼容。改用 Ruby 1.9.2
  • 只有 1.9.1 有问题还是所有版本

标签: ruby-on-rails sqlite cucumber jruby celerity


【解决方案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 上可用

【讨论】:

  • 这行得通。我所要做的就是在我的 Gemfile 中指定 0.6.0 ,它就像一个魅力。谢谢!
【解决方案2】:

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

宝石:activerecord-jdbcsqlite3-adapterjdbc-sqlite3

(我总是同时安装,你最好只用activerecord-jdbcsqlite3-adapter

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

cucumber:
  adapter: jdbcsqlite3
  database: db/development.sqlite3
  timeout: 5000

【讨论】:

  • 我目前用的是mysql,不是sqlite3。我确实尝试切换到 sqlite3 以查看是否可以解决问题(它没有)并且我确实使用了 jdbc 适配器。感谢您的意见!
猜你喜欢
  • 2012-10-21
  • 2018-06-06
  • 1970-01-01
  • 1970-01-01
  • 2013-05-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-03-02
相关资源
最近更新 更多