Class: AppTester::Connection Abstract
- Inherits:
-
Object
- Object
- AppTester::Connection
- Defined in:
- lib/app-tester/connection.rb
Overview
This class is abstract.
Connection object that deals with communicating with Faraday to build new connections
Instance Attribute Summary collapse
-
#options ⇒ AppTester::Options
readonly
the options that the user defined when he created the framework.
Class Method Summary collapse
-
.new(url = "", options = {}) ⇒ Faraday::Connection
Build a new connection handler.
Instance Attribute Details
#options ⇒ AppTester::Options (readonly)
the options that the user defined when he created the framework
6 7 8 |
# File 'lib/app-tester/connection.rb', line 6 def @options end |
Class Method Details
.new(url = "", options = {}) ⇒ Faraday::Connection
TODO:
Implement connection retry
Build a new connection handler
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/app-tester/connection.rb', line 21 def self.new(url="", ={}) @options = # Make sure server choice makes sense raise OptionParser::InvalidArgument if url.nil? puts AppTester::Utils::Colours.dark_gray "Connecting to #{url}..." retries = 0 connection = Faraday.new(:url => url, :ssl => { :verify => false }) do |builder| builder.request :url_encoded builder.adapter :net_http builder.response :logger if @options.log_connections end connection #begin # # connection.get do |req| # # end #rescue Faraday::Error::ConnectionFailed => e # retries += 1 # if retries <= @options.connection_retries # puts AppTester::Utils::Colours.dark_gray "#{AppTester::Utils::Strings::FAILED} Failed connection to #{url}, retry attempt #{retries}..." # retry # end # raise Faraday::Error::ConnectionFailed(e.message) #end end |