黄瓜防止清除数据库

发布于 2024-09-15 17:41:21 字数 1024 浏览 6 评论 0原文

由于项目规模不断增长,我遇到了黄瓜数据库重建过程确实需要很长时间的麻烦。

由于它是一个表的实际内容并不重要的应用程序,因此我想跳过重建过程。

不幸的是,黄瓜和database_cleaner似乎都支持这一点,不是吗?

我的黄瓜环境设置可以在下面找到

谢谢并致以诚挚的问候,

ENV["RAILS_ENV"] ||= "cucumber"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')

require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
require 'cucumber/rails/world'
require 'cucumber/rails/active_record'
require 'cucumber/web/tableish'

require 'capybara/rails'
require 'capybara/cucumber'
require 'capybara/session'
require 'cucumber/rails/capybara_javascript_emulation'

Capybara.default_selector = :css

ActionController::Base.allow_rescue = false

Cucumber::Rails::World.use_transactional_fixtures = false

Capybara.default_driver = :selenium

if defined?(ActiveRecord::Base)
  begin
    require 'database_cleaner'
    DatabaseCleaner.strategy = :truncation
  rescue LoadError => ignore_if_database_cleaner_not_present
  end
end

due to a heavy growing project I'm running into the trouble that the database rebuild process of cucumber really takes a long time.

Since it is a application where the actual content of the table doesn't matter, I'd like to skip the rebuild process.

Unfortunately wether cucumber nor database_cleaner seem to support this, doesn't they?

My cucumber env settings may be found below

Thanks and many regards,

Joe

ENV["RAILS_ENV"] ||= "cucumber"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')

require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
require 'cucumber/rails/world'
require 'cucumber/rails/active_record'
require 'cucumber/web/tableish'

require 'capybara/rails'
require 'capybara/cucumber'
require 'capybara/session'
require 'cucumber/rails/capybara_javascript_emulation'

Capybara.default_selector = :css

ActionController::Base.allow_rescue = false

Cucumber::Rails::World.use_transactional_fixtures = false

Capybara.default_driver = :selenium

if defined?(ActiveRecord::Base)
  begin
    require 'database_cleaner'
    DatabaseCleaner.strategy = :truncation
  rescue LoadError => ignore_if_database_cleaner_not_present
  end
end

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

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

发布评论

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

评论(1

尤怨 2024-09-22 17:41:21

阻止 database_cleaner 清理某个表的一种简单方法是将其配置如下:

DatabaseCleaner.strategy = :truncation, {:except => %w[states]}

在本例中,一旦表 states 加载了信息,它就不会清洁它。

An easy way to stop database_cleaner from cleaning one of your tables is to configure it like this:

DatabaseCleaner.strategy = :truncation, {:except => %w[states]}

In this example, once the table states is loaded with information, it doesn't clean it.

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