之前我使用的是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!"
我该如何压制?有办法吗,对吧?
答案 0 :(得分:18)
您是否将config.use_transactional_examples = true
设置为false并查看是否会破坏任何内容?
答案 1 :(得分:4)
我设置了config.use_transactional_fixtures = true
。这是默认值(使用rails g rspec:install
生成spec_helper)。我使用FactoryGirl而不是灯具,摆脱了这个设置删除警告。
答案 2 :(得分:0)
禁用交易
如果您更喜欢自己管理数据,或者使用其他工具 database_cleaner为你做的,只需告诉RSpec告诉Rails不管理事务:
RSpec.configure do | config | config.use_transactional_fixtures = false 端
https://www.relishapp.com/rspec/rspec-rails/docs/transactions