ruby-on-rails – 如何从Rspec输出中禁用http日志?

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 如何从Rspec输出中禁用http日志?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在为我的rails应用程序编写测试.
我只想看到’.’当rspec运行时,和’*’符号.
但我正在观看HTTP日志,不知道如何禁用它们.
我终端输出的一块rspec: @H_404_5@.............get http://0.0.0.0:3000/device_info/?api_session=%23%7Bapi_session%7D User-Agent: "Faraday v0.8.7" 404 content-type: "text/html" x-cascade: "pass" connection: "close" server: "thin 1.5.1 codename Straight Razor" .....get http://0.0.0.0:3000/device_info/12345?api_session=%23%7Bapi_session%7D User-Agent: "Faraday v0.8.7" 400 .. .............get http://0.0.0.0:3000/device_info/?api_session=%23%7Bapi_session%7D User-Agent: "Faraday v0.8.7" 404 content-type: "text/html" x-cascade: "pass" connection: "close" server: "thin 1.5.1 codename Straight Razor" .....get http://0.0.0.0:3000/device_info/12345?api_session=%23%7Bapi_session%7D User-Agent: "Faraday v0.8.7" 400 ..

我假设原因可能是’法拉第’宝石的配置.
如何从我的rspec输出中禁用此日志?

解决方法

法拉第不会默认记录任何内容: @H_404_5@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=[]>

我假设你的应用程序中有一些配置块,如下所示:

@H_404_5@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'

如果删除记录器行,则不应该有任何输出到STDOUT.

原文链接:https://www.f2er.com/ruby/268631.html

猜你在找的Ruby相关文章