From 3bc51e96c7a88dfdf8d003c669d4af33d92ab90c Mon Sep 17 00:00:00 2001 From: Zack Hobson Date: Mon, 21 Apr 2014 12:56:40 -0700 Subject: remove dependency on fakeweb and net::http By using pure faraday for the test and error handling code, the way is cleared for dropping in alternative http clients. --- lib/hcl/app.rb | 2 +- lib/hcl/net.rb | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/hcl/app.rb b/lib/hcl/app.rb index 0cda7b4..14f626d 100644 --- a/lib/hcl/app.rb +++ b/lib/hcl/app.rb @@ -66,7 +66,7 @@ module HCl rescue RuntimeError => e $stderr.puts "Error: #{e}" exit 1 - rescue SocketError => e + rescue Faraday::Error => e $stderr.puts "Connection failed. (#{e.message})" exit 1 rescue HarvestMiddleware::ThrottleFailure => e diff --git a/lib/hcl/net.rb b/lib/hcl/net.rb index 730e5b4..ac794d6 100644 --- a/lib/hcl/net.rb +++ b/lib/hcl/net.rb @@ -19,7 +19,11 @@ module HCl "https://#{subdomain}.harvestapp.com" ) do |f| f.use :harvest, login, password - f.adapter Faraday.default_adapter + if opts['test_adapter'] + f.adapter :test, opts['test_adapter'] + else + f.adapter Faraday.default_adapter + end end end -- cgit v1.2.3