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:
.............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
..
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'
if you remove the logger
line, than there should not be any output to STDOUT.
Just remove the response :logger
config when testing (!Rails.env.test?
)
Faraday.new(url: endpoint) do |faraday|
faraday.request :url_encoded
faraday.response :logger if !Rails.env.test?
faraday.adapter Faraday.default_adapter
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With