Rspec:如何在运行测试时禁止警告和通知?

时间:2012-06-16 16:53:06

标签: ruby-on-rails-3 postgresql rspec2 rails-postgresql

之前我使用的是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!"

我该如何压制?有办法吗,对吧?

3 个答案:

答案 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