twitter-status-bot/.gems/gems/faraday-0.9.0/test/adapters/logger_test.rb

38 lines
915 B
Ruby
Raw Normal View History

2014-09-03 08:49:59 +00:00
require File.expand_path('../../helper', __FILE__)
require 'stringio'
require 'logger'
module Adapters
class LoggerTest < Faraday::TestCase
def setup
@io = StringIO.new
@logger = Logger.new(@io)
@logger.level = Logger::DEBUG
@conn = Faraday.new do |b|
b.response :logger, @logger
b.adapter :test do |stubs|
stubs.get('/hello') { [200, {'Content-Type' => 'text/html'}, 'hello'] }
end
end
@resp = @conn.get '/hello', nil, :accept => 'text/html'
end
def test_still_returns_output
assert_equal 'hello', @resp.body
end
def test_logs_method_and_url
assert_match "get http:/hello", @io.string
end
def test_logs_request_headers
assert_match %(Accept: "text/html), @io.string
end
def test_logs_response_headers
assert_match %(Content-Type: "text/html), @io.string
end
end
end