Rails 3 and Rspec 2 turn off transactional fixtures for individual tests

ぐ巨炮叔叔 提交于 2019-12-03 02:40:02

I'm looking for the answer to this question, came across this blog entry

It suggests to declare inside the describe block

describe "xxx" do
  self.use_transactional_fixtures = false
  ...

I tried it with Rails 3.0.7 with RSpec 2.6.3, and looks like working.

RSpec.configure do |config|
  config.use_transactional_fixtures = true
end

You can disable transactional fixtures globally by putting config.use_transactional_fixtures = false on the spec_helper.rb. If you want to control them by test (e.g. use transactional just on some of them), you can set this behavior with DatabaseCleaner.

I've had a related problem when testing pages with javascript on the browser (a scenario that does not work with transactional fixtures). Here's how I managed to work around it: http://github.com/lailsonbm/contact_manager_app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!