如何禁用来自Rspec输出的http日志? [英] How disable http logs from Rspec output?
本文介绍了如何禁用来自Rspec输出的http日志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为我的rails应用程序编写测试。
当rspec运行时,我只想看到'。'和'*'符号。
但是我正在看HTTP日志,不知道如何禁用它们。
从我的终端输出rspec:
I'm writing tests for my rails application. I want to see only '.' and '*' symbols, when rspec running. But I'm watching HTTP logs and don't know how disable them. Piece of rspec output from my terminal:
我假设原因可能是'法拉第'宝石的配置。
I assume that the reason may be configuration of 'faraday' gem. How can I disable this logs from my rspec output?
推荐答案
法拉第在默认情况下不记录任何内容:
faraday does not log anything per default:
irb(main):001:0> require "faraday"
=> true
irb(main):002:0> Faraday.get 'http://sushi.com/nigiri/sake.json'
=> #<Faraday::Response:0x007ff48f0422a8 @env={:method=>:get, :body=>"", :url=>#<URI::HTTP:0x007ff48f03bd40 URL:http://sushi.com/nigiri/sake.json>, :request_headers=>{"User-Agent"=>"Faraday v0.8.7"}, :parallel_manager=>nil, :request=>{:proxy=>nil}, :ssl=>{}, :status=>302, :response_headers=>{"date"=>"Thu, 25 Jul 2013 14:36:42 GMT", "server"=>"Apache/2.2.22 (Ubuntu)", "x-powered-by"=>"PHP/5.3.10-1ubuntu3.6", "location"=>"http://sushi.com/?f", "vary"=>"Accept-Encoding", "content-length"=>"20", "connection"=>"close", "content-type"=>"text/html", "set-cookie"=>"WEBUK=WUK08; path=/"}, :response=>#<Faraday::Response:0x007ff48f0422a8 ...>}, @on_complete_callbacks=[]>
我假设您的应用程序中有一些配置块,如下所示:
i assume that you have some configuration block in your app like this:
conn = Faraday.new(:url => 'http://sushi.com') do |faraday|
faraday.request :url_encoded
faraday.response :logger
faraday.adapter Faraday.default_adapter
end
conn.get '/nigiri/sake.json'
如果删除 logger
不是任何输出到STDOUT。
if you remove the logger
line, than there should not be any output to STDOUT.
这篇关于如何禁用来自Rspec输出的http日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文