Class: ApiTester::Connection
- Inherits:
-
Object
- Object
- ApiTester::Connection
- Defined in:
- lib/api_tester/connection.rb
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(endpoint, options = {}) ⇒ Connection
constructor
A new instance of Connection.
- #pretty_print(resp) ⇒ Object
Constructor Details
#initialize(endpoint, options = {}) ⇒ Connection
Returns a new instance of Connection.
7 8 9 |
# File 'lib/api_tester/connection.rb', line 7 def initialize(endpoint, = {}) @endpoint = endpoint end |
Instance Method Details
#connection ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/api_tester/connection.rb', line 11 def connection @conn ||= Faraday.new(:url => @endpoint) do |faraday| faraday.request :url_encoded faraday.response :logger if ApiTester.configuration.[:verbose] faraday.adapter Faraday.default_adapter end end |
#pretty_print(resp) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/api_tester/connection.rb', line 31 def pretty_print(resp) begin puts JSON.pretty_generate(JSON.parse(resp.body)) rescue puts resp.body end end |