Nic*_*o77 11 rspec ruby-on-rails rspec2
我正在将我的应用程序升级到Rails 3.我开始在Rails 3中使用Rspec 2.我需要为我的一些rspec测试关闭事务装置.之前我在我的模型规范中使用了以下代码
before(:all) do
ActiveSupport::TestCase.use_transactional_fixtures = false
end
after(:all) do
ActiveSupport::TestCase.use_transactional_fixtures = true
clean_engine_database
end
Run Code Online (Sandbox Code Playgroud)
那现在给了我错误:
Failure/Error: ActiveSupport::TestCase.use_transactional_fixtures = false
undefined method `use_transactional_fixtures=' for ActiveSupport::TestCase:Class
Run Code Online (Sandbox Code Playgroud)
有没有办法在Rails 3中使用Rspec 2的每个测试块执行此操作?
shi*_*eya 19
我正在寻找这个问题的答案,遇到了这篇博客文章
它建议在describe块中声明
describe "xxx" do
self.use_transactional_fixtures = false
...
Run Code Online (Sandbox Code Playgroud)
我用Rails 3.0.7和RSpec 2.6.3一起尝试了,看起来像是在工作.
归档时间: |
|
查看次数: |
9110 次 |
最近记录: |