10

我之前使用的是 Mysql 数据库并决定切换到 Postgresql,现在,当我使用 rspec 运行测试时,我收到了很多警告和通知。

WARNING:  there is already a transaction in progress
NOTICE:  there is no transaction in progress
      should has link "Suspender"
WARNING:  there is already a transaction in progress
NOTICE:  there is no transaction in progress
      should has css "title" with text "Suspensão de anúncio"
WARNING:  there is already a transaction in progress
NOTICE:  there is no transaction in progress
      should has css "h1" with text "Awesome job!"

我怎么能压制它?有没有办法,对吧?

4

3 回答 3

18

您是否设置:config.use_transactional_examples = true为 false 并查看是否会破坏任何内容?

于 2012-06-17T04:27:00.220 回答
4

我已经config.use_transactional_fixtures = true定了。这是默认设置(使用 生成的 spec_helper rails g rspec:install)。我使用的是 FactoryGirl 而不是固定装置,摆脱了这个设置删除了警告。

于 2012-08-08T20:05:59.477 回答
0

禁用事务

如果您更喜欢自己管理数据,或者使用其他工具(如 database_cleaner)为您完成,只需告诉 RSpec 告诉 Rails 不要管理事务:

RSpec.configure 做 |config| config.use_transactional_fixtures = 假结束

https://www.relishapp.com/rspec/rspec-rails/docs/transactions

于 2013-01-25T19:28:15.880 回答