# encoding: utf-8 require 'spec_helper' describe Reporters::FetchUrls do context '#initialize' do it 'does not require any parameter' do expect { Reporters::FetchUrls.new }.not_to raise_error end it 'accepts an io object' do expect { Reporters::FetchUrls.new(StringIO.new) }.not_to raise_error end end context '#data' do let(:data) { { headers: { "Date" => "Fri, 21 Mar 2014 09:49:09 GMT", "Server" => "Apache", "Location" => "http://www.sg-zertifikate.de/dwr/call/plainpoll/ReverseAjax.dwr", "Content-Length" => "271", "Content-Type" => "text/html; charset=iso-8859-1", "Connection" => "close", "Age" => "1" }, status: 301, url: 'http://www.sg-zertifikate.de/dwr/call/plainpoll/ReverseAjax.dwr', proxy: 'proxy:3128', } } it 'generates output' do reporter = Reporters::FetchUrls.new result = capture :stdout do reporter.data(data) end expect(result).to match(/url\s+:/) end it 'uses io object' do output = StringIO.new reporter = Reporters::FetchUrls.new(output) reporter.data(data) expect(output.string).to match(/url\s+:/) end end end