【发布时间】:2012-01-08 00:02:22
【问题描述】:
似乎最普遍接受的处理 Selenium 和测试的方法是避免使用事务性固定装置,然后在测试/场景之间使用诸如 database_cleaner 之类的东西。我最近遇到了以下article,它建议执行以下操作:
spec_helper.rb
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || retrieve_connection
end
end
# Forces all threads to share the same connection. This works on
# Capybara because it starts the web server in a thread.
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
这似乎比其他选项更能提高性能。有没有人有任何理由不应该使用它?
【问题讨论】:
标签: ruby-on-rails ruby rspec capybara