[英]Rspec: How to suppress warnings and notices when running tests?
我之前使用的是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!"
我怎么能壓制那個? 有辦法嗎,對嗎?
您是否將: config.use_transactional_examples = true
設置為false並查看是否會破壞任何內容?
我有config.use_transactional_fixtures = true
set。 這是默認值(使用rails g rspec:install
生成spec_helper)。 我使用FactoryGirl而不是燈具,擺脫這個設置刪除警告。
禁用交易
如果您更喜歡自己管理數據,或者使用像database_cleaner這樣的其他工具來為您完成,只需告訴RSpec告訴Rails不要管理事務:
RSpec.configure do | config | config.use_transactional_fixtures = false結束
https://www.relishapp.com/rspec/rspec-rails/docs/transactions
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.