使用 mysql 在 Jruby on Rails 应用程序上运行 Cucumber/capybara/celerity 集成测试

发布于 2024-09-29 02:55:58 字数 2879 浏览 5 评论 0原文

我有一个正在使用 ruby​​ 1.9.1 开发的应用程序。我想在我的 UI 中测试 javascript,但水豚的默认 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,测试就会运行,但它们都会神秘地失败。

有人知道这是怎么回事吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

放飞的风筝 2024-10-06 02:55:59

看来这是数据库清理器和 jdbc 交互方式的问题。

http://github.com/tmikoss/database_cleaner/commit/83d85cf7740e4aef97dd6fd5c0908cb09a2 f0ca9

更新:
我发现这个问题是因为我正在努力解决同样的问题。我上面链接的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上可用

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

自此以后,行同陌路 2024-10-06 02:55:59

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

Gems:activerecord-jdbcsqlite3-adapterjdbc-sqlite3

(我总是安装两者,您可能只使用activerecord -jdbcsqlite3-adapter)

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

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文