faraday 0.9.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +1 -1
  3. data/README.md +53 -16
  4. data/lib/faraday/adapter/em_http.rb +8 -2
  5. data/lib/faraday/adapter/em_http_ssl_patch.rb +1 -1
  6. data/lib/faraday/adapter/em_synchrony.rb +16 -2
  7. data/lib/faraday/adapter/excon.rb +7 -7
  8. data/lib/faraday/adapter/httpclient.rb +27 -5
  9. data/lib/faraday/adapter/net_http.rb +13 -8
  10. data/lib/faraday/adapter/net_http_persistent.rb +6 -4
  11. data/lib/faraday/adapter/patron.rb +13 -9
  12. data/lib/faraday/adapter/test.rb +64 -21
  13. data/lib/faraday/adapter.rb +8 -1
  14. data/lib/faraday/connection.rb +14 -9
  15. data/lib/faraday/error.rb +11 -1
  16. data/lib/faraday/options.rb +18 -1
  17. data/lib/faraday/parameters.rb +54 -38
  18. data/lib/faraday/rack_builder.rb +3 -2
  19. data/lib/faraday/request/authorization.rb +1 -2
  20. data/lib/faraday/request/retry.rb +10 -4
  21. data/lib/faraday/request.rb +2 -0
  22. data/lib/faraday/response/logger.rb +27 -6
  23. data/lib/faraday/response.rb +6 -2
  24. data/lib/faraday/utils.rb +22 -2
  25. data/lib/faraday.rb +8 -33
  26. metadata +7 -93
  27. data/.document +0 -6
  28. data/CHANGELOG.md +0 -20
  29. data/CONTRIBUTING.md +0 -36
  30. data/Gemfile +0 -25
  31. data/Rakefile +0 -71
  32. data/faraday.gemspec +0 -34
  33. data/script/cached-bundle +0 -46
  34. data/script/console +0 -7
  35. data/script/generate_certs +0 -42
  36. data/script/package +0 -7
  37. data/script/proxy-server +0 -42
  38. data/script/release +0 -17
  39. data/script/s3-put +0 -71
  40. data/script/server +0 -36
  41. data/script/test +0 -172
  42. data/test/adapters/default_test.rb +0 -14
  43. data/test/adapters/em_http_test.rb +0 -20
  44. data/test/adapters/em_synchrony_test.rb +0 -20
  45. data/test/adapters/excon_test.rb +0 -20
  46. data/test/adapters/httpclient_test.rb +0 -21
  47. data/test/adapters/integration.rb +0 -254
  48. data/test/adapters/logger_test.rb +0 -82
  49. data/test/adapters/net_http_persistent_test.rb +0 -20
  50. data/test/adapters/net_http_test.rb +0 -14
  51. data/test/adapters/patron_test.rb +0 -20
  52. data/test/adapters/rack_test.rb +0 -31
  53. data/test/adapters/test_middleware_test.rb +0 -114
  54. data/test/adapters/typhoeus_test.rb +0 -28
  55. data/test/authentication_middleware_test.rb +0 -65
  56. data/test/composite_read_io_test.rb +0 -111
  57. data/test/connection_test.rb +0 -522
  58. data/test/env_test.rb +0 -218
  59. data/test/helper.rb +0 -81
  60. data/test/live_server.rb +0 -67
  61. data/test/middleware/instrumentation_test.rb +0 -88
  62. data/test/middleware/retry_test.rb +0 -177
  63. data/test/middleware_stack_test.rb +0 -173
  64. data/test/multibyte.txt +0 -1
  65. data/test/options_test.rb +0 -252
  66. data/test/parameters_test.rb +0 -64
  67. data/test/request_middleware_test.rb +0 -142
  68. data/test/response_middleware_test.rb +0 -72
  69. data/test/strawberry.rb +0 -2
  70. data/test/utils_test.rb +0 -58
data/script/test DELETED
@@ -1,172 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Usage: script/test [file] [adapter]... -- [test/unit options]
3
- # Runs the test suite against a local server spawned automatically in a
4
- # thread. After tests are done, the server is shut down.
5
- #
6
- # If filename arguments are given, only those files are run. If arguments given
7
- # are not filenames, they are taken as words that filter the list of files to run.
8
- #
9
- # Examples:
10
- #
11
- # $ script/test
12
- # $ script/test test/env_test.rb
13
- # $ script/test excon typhoeus
14
- #
15
- # # Run only tests matching /ssl/ for the net_http adapter, with SSL enabled.
16
- # $ SSL=yes script/test net_http -- -n /ssl/
17
- #
18
- # # Run against multiple rbenv versions
19
- # $ RBENV_VERSIONS="1.9.3-p194 ree-1.8.7-2012.02" script/test
20
- set -e
21
-
22
- if [[ "$RUBYOPT" != *"bundler/setup"* ]]; then
23
- export RUBYOPT="-rbundler/setup $RUBYOPT"
24
- fi
25
-
26
- port=3999
27
- proxy_port=3998
28
- scheme=http
29
-
30
- if [ "$SSL" = "yes" ]; then
31
- scheme=https
32
- if [ -z "$SSL_KEY" ] || [ -z "$SSL_FILE" ]; then
33
- eval "$(script/generate_certs -s)"
34
- fi
35
- fi
36
-
37
- find_test_files() {
38
- find "$1" -name '*_test.rb'
39
- }
40
-
41
- filter_matching() {
42
- pattern="$1"
43
- shift
44
- for line in "$@"; do
45
- [[ $line == *"$pattern"* ]] && echo "$line"
46
- done
47
- }
48
-
49
- start_server() {
50
- mkdir -p log
51
- script/server -p $port >log/test.log 2>&1 &
52
- echo $!
53
- }
54
-
55
- start_proxy() {
56
- mkdir -p log
57
- script/proxy-server -p $proxy_port -u "faraday@test.local:there is cake" >log/proxy.log 2>&1 &
58
- echo $!
59
- }
60
-
61
- server_started() {
62
- lsof -i :${1?} >/dev/null
63
- }
64
-
65
- timestamp() {
66
- date +%s
67
- }
68
-
69
- wait_for_server() {
70
- timeout=$(( `timestamp` + $1 ))
71
- while true; do
72
- if server_started "$2"; then
73
- break
74
- elif [ `timestamp` -gt "$timeout" ]; then
75
- echo "timed out after $1 seconds" >&2
76
- return 1
77
- fi
78
- done
79
- }
80
-
81
- filtered=
82
- IFS=$'\n' test_files=($(find_test_files "test"))
83
- declare -a explicit_files
84
-
85
- # Process filter arguments:
86
- # - test filenames as taken as-is
87
- # - other words are taken as pattern to match the list of known files against
88
- # - arguments after "--" are forwarded to the ruby process
89
- while [ $# -gt 0 ]; do
90
- arg="$1"
91
- shift
92
- if [ "$arg" = "--" ]; then
93
- break
94
- elif [ -f "$arg" ]; then
95
- filtered=true
96
- explicit_files[${#explicit_files[@]}+1]="$arg"
97
- else
98
- filtered=true
99
- IFS=$'\n' explicit_files=(
100
- ${explicit_files[@]}
101
- $(filter_matching "$arg" "${test_files[@]}" || true)
102
- )
103
- fi
104
- done
105
-
106
- # If there were filter args, replace test files list with the results
107
- if [ -n "$filtered" ]; then
108
- if [ ${#explicit_files[@]} -eq 0 ]; then
109
- echo "Error: no test files match" >&2
110
- exit 1
111
- else
112
- test_files=(${explicit_files[@]})
113
- echo running "${test_files[@]}"
114
- fi
115
- fi
116
-
117
- # If there are any adapter tests, spin up the HTTP server
118
- if [ -n "$(filter_matching "adapters" "${test_files[@]}")" ]; then
119
- if server_started $port; then
120
- echo "aborted: another instance of server running on $port" >&2
121
- exit 1
122
- fi
123
- server_pid=$(start_server)
124
- proxy_pid=$(start_proxy)
125
- wait_for_server 30 $port || {
126
- cat log/test.log
127
- kill "$server_pid"
128
- kill "$proxy_pid"
129
- exit 1
130
- }
131
- wait_for_server 5 $proxy_port
132
- cleanup() {
133
- if [ $? -ne 0 ] && [ -n "$TRAVIS" ]; then
134
- cat log/test.log
135
- fi
136
- kill "$server_pid"
137
- kill "$proxy_pid"
138
- }
139
- trap cleanup INT EXIT
140
- export LIVE="${scheme}://localhost:${port}"
141
- export LIVE_PROXY="http://faraday%40test.local:there%20is%20cake@localhost:${proxy_port}"
142
- fi
143
-
144
- warnings="${TMPDIR:-/tmp}/faraday-warnings.$$"
145
-
146
- run_test_files() {
147
- # Save warnings on stderr to a separate file
148
- RUBYOPT="$RUBYOPT -w" ruby -e 'while f=ARGV.shift and f!="--"; load f; end' "${test_files[@]}" -- "$@" \
149
- 2> >(tee >(grep 'warning:' >"$warnings") | grep -v 'warning:')
150
- }
151
-
152
- check_warnings() {
153
- # Display Ruby warnings from this project's source files. Abort if any were found.
154
- num="$(grep -F "$PWD" "$warnings" | grep -v "${PWD}/bundle" | sort | uniq -c | sort -rn | tee /dev/stderr | wc -l)"
155
- rm -f "$warnings"
156
- if [ "$num" -gt 0 ]; then
157
- echo "FAILED: this test suite doesn't tolerate Ruby syntax warnings!" >&2
158
- exit 1
159
- fi
160
- }
161
-
162
- if [ -n "$RBENV_VERSIONS" ]; then
163
- IFS=' ' versions=($RBENV_VERSIONS)
164
- for version in "${versions[@]}"; do
165
- echo "[${version}]"
166
- RBENV_VERSION="$version" run_test_files "$@"
167
- done
168
- else
169
- run_test_files "$@"
170
- fi
171
-
172
- check_warnings
@@ -1,14 +0,0 @@
1
- require File.expand_path('../integration', __FILE__)
2
-
3
- module Adapters
4
- class DefaultTest < Faraday::TestCase
5
-
6
- def adapter() :default end
7
-
8
- Integration.apply(self, :NonParallel) do
9
- # default stack is not configured with Multipart
10
- undef :test_POST_sends_files
11
- end
12
-
13
- end
14
- end
@@ -1,20 +0,0 @@
1
- require File.expand_path('../integration', __FILE__)
2
-
3
- module Adapters
4
- class EMHttpTest < Faraday::TestCase
5
-
6
- def adapter() :em_http end
7
-
8
- Integration.apply(self, :Parallel) do
9
- # https://github.com/eventmachine/eventmachine/pull/289
10
- undef :test_timeout
11
-
12
- def test_binds_local_socket
13
- host = '1.2.3.4'
14
- conn = create_connection :request => { :bind => { :host => host } }
15
- assert_equal host, conn.options[:bind][:host]
16
- end
17
- end unless jruby? and ssl_mode?
18
- # https://github.com/eventmachine/eventmachine/issues/180
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- require File.expand_path('../integration', __FILE__)
2
-
3
- module Adapters
4
- class EMSynchronyTest < Faraday::TestCase
5
-
6
- def adapter() :em_synchrony end
7
-
8
- Integration.apply(self, :Parallel) do
9
- # https://github.com/eventmachine/eventmachine/pull/289
10
- undef :test_timeout
11
-
12
- def test_binds_local_socket
13
- host = '1.2.3.4'
14
- conn = create_connection :request => { :bind => { :host => host } }
15
- #put conn.get('/who-am-i').body
16
- assert_equal host, conn.options[:bind][:host]
17
- end
18
- end unless RUBY_VERSION < '1.9' or jruby?
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- require File.expand_path('../integration', __FILE__)
2
-
3
- module Adapters
4
- class ExconTest < Faraday::TestCase
5
-
6
- def adapter() :excon end
7
-
8
- Integration.apply(self, :NonParallel) do
9
- # https://github.com/geemus/excon/issues/126 ?
10
- undef :test_timeout if ssl_mode?
11
-
12
- # Excon lets OpenSSL::SSL::SSLError be raised without any way to
13
- # distinguish whether it happened because of a 407 proxy response
14
- undef :test_proxy_auth_fail if ssl_mode?
15
-
16
- # https://github.com/geemus/excon/issues/358
17
- undef :test_connection_error if RUBY_VERSION >= '2.1.0'
18
- end
19
- end
20
- end
@@ -1,21 +0,0 @@
1
- require File.expand_path('../integration', __FILE__)
2
-
3
- module Adapters
4
- class HttpclientTest < Faraday::TestCase
5
-
6
- def adapter() :httpclient end
7
-
8
- Integration.apply(self, :NonParallel) do
9
- def setup
10
- require 'httpclient' unless defined?(HTTPClient)
11
- HTTPClient::NO_PROXY_HOSTS.delete('localhost')
12
- end
13
-
14
- def test_binds_local_socket
15
- host = '1.2.3.4'
16
- conn = create_connection :request => { :bind => { :host => host } }
17
- assert_equal host, conn.options[:bind][:host]
18
- end
19
- end
20
- end
21
- end
@@ -1,254 +0,0 @@
1
- require 'forwardable'
2
- require File.expand_path("../../helper", __FILE__)
3
- Faraday.require_lib 'autoload'
4
-
5
- module Adapters
6
- # Adapter integration tests. To use, implement two methods:
7
- #
8
- # `#adapter` required. returns a symbol for the adapter middleware name
9
- # `#adapter_options` optional. extra arguments for building an adapter
10
- module Integration
11
- def self.apply(base, *extra_features)
12
- if base.live_server?
13
- features = [:Common]
14
- features.concat extra_features
15
- features << :SSL if base.ssl_mode?
16
- features.each {|name| base.send(:include, self.const_get(name)) }
17
- yield if block_given?
18
- elsif !defined? @warned
19
- warn "Warning: Not running integration tests against a live server."
20
- warn "Start the server `ruby test/live_server.rb` and set the LIVE=1 env variable."
21
- @warned = true
22
- end
23
- end
24
-
25
- module Parallel
26
- def test_in_parallel
27
- resp1, resp2 = nil, nil
28
-
29
- connection = create_connection
30
- connection.in_parallel do
31
- resp1 = connection.get('echo?a=1')
32
- resp2 = connection.get('echo?b=2')
33
- assert connection.in_parallel?
34
- assert_nil resp1.body
35
- assert_nil resp2.body
36
- end
37
- assert !connection.in_parallel?
38
- assert_equal 'get ?{"a"=>"1"}', resp1.body
39
- assert_equal 'get ?{"b"=>"2"}', resp2.body
40
- end
41
- end
42
-
43
- module NonParallel
44
- def test_no_parallel_support
45
- connection = create_connection
46
- response = nil
47
-
48
- err = capture_warnings do
49
- connection.in_parallel do
50
- response = connection.get('echo').body
51
- end
52
- end
53
- assert response
54
- assert_match "no parallel-capable adapter on Faraday stack", err
55
- assert_match __FILE__, err
56
- end
57
- end
58
-
59
- module Compression
60
- def test_GET_handles_compression
61
- res = get('echo_header', :name => 'accept-encoding')
62
- assert_match(/gzip;.+\bdeflate\b/, res.body)
63
- end
64
- end
65
-
66
- module SSL
67
- def test_GET_ssl_fails_with_bad_cert
68
- ca_file = 'tmp/faraday-different-ca-cert.crt'
69
- conn = create_connection(:ssl => {:ca_file => ca_file})
70
- err = assert_raises Faraday::SSLError do
71
- conn.get('/ssl')
72
- end
73
- assert_includes err.message, "certificate"
74
- end
75
- end
76
-
77
- module Common
78
- extend Forwardable
79
- def_delegators :create_connection, :get, :head, :put, :post, :patch, :delete, :run_request
80
-
81
- def test_GET_retrieves_the_response_body
82
- assert_equal 'get', get('echo').body
83
- end
84
-
85
- def test_GET_send_url_encoded_params
86
- assert_equal %(get ?{"name"=>"zack"}), get('echo', :name => 'zack').body
87
- end
88
-
89
- def test_GET_retrieves_the_response_headers
90
- response = get('echo')
91
- assert_match(/text\/plain/, response.headers['Content-Type'], 'original case fail')
92
- assert_match(/text\/plain/, response.headers['content-type'], 'lowercase fail')
93
- end
94
-
95
- def test_GET_handles_headers_with_multiple_values
96
- assert_equal 'one, two', get('multi').headers['set-cookie']
97
- end
98
-
99
- def test_GET_with_body
100
- response = get('echo') do |req|
101
- req.body = {'bodyrock' => true}
102
- end
103
- assert_equal %(get {"bodyrock"=>"true"}), response.body
104
- end
105
-
106
- def test_GET_sends_user_agent
107
- response = get('echo_header', {:name => 'user-agent'}, :user_agent => 'Agent Faraday')
108
- assert_equal 'Agent Faraday', response.body
109
- end
110
-
111
- def test_GET_ssl
112
- expected = self.class.ssl_mode?.to_s
113
- assert_equal expected, get('ssl').body
114
- end
115
-
116
- def test_POST_send_url_encoded_params
117
- assert_equal %(post {"name"=>"zack"}), post('echo', :name => 'zack').body
118
- end
119
-
120
- def test_POST_send_url_encoded_nested_params
121
- resp = post('echo', 'name' => {'first' => 'zack'})
122
- assert_equal %(post {"name"=>{"first"=>"zack"}}), resp.body
123
- end
124
-
125
- def test_POST_retrieves_the_response_headers
126
- assert_match(/text\/plain/, post('echo').headers['content-type'])
127
- end
128
-
129
- def test_POST_sends_files
130
- resp = post('file') do |req|
131
- req.body = {'uploaded_file' => Faraday::UploadIO.new(__FILE__, 'text/x-ruby')}
132
- end
133
- assert_equal "file integration.rb text/x-ruby #{File.size(__FILE__)}", resp.body
134
- end
135
-
136
- def test_PUT_send_url_encoded_params
137
- assert_equal %(put {"name"=>"zack"}), put('echo', :name => 'zack').body
138
- end
139
-
140
- def test_PUT_send_url_encoded_nested_params
141
- resp = put('echo', 'name' => {'first' => 'zack'})
142
- assert_equal %(put {"name"=>{"first"=>"zack"}}), resp.body
143
- end
144
-
145
- def test_PUT_retrieves_the_response_headers
146
- assert_match(/text\/plain/, put('echo').headers['content-type'])
147
- end
148
-
149
- def test_PATCH_send_url_encoded_params
150
- assert_equal %(patch {"name"=>"zack"}), patch('echo', :name => 'zack').body
151
- end
152
-
153
- def test_OPTIONS
154
- resp = run_request(:options, 'echo', nil, {})
155
- assert_equal 'options', resp.body
156
- end
157
-
158
- def test_HEAD_retrieves_no_response_body
159
- assert_equal '', head('echo').body
160
- end
161
-
162
- def test_HEAD_retrieves_the_response_headers
163
- assert_match(/text\/plain/, head('echo').headers['content-type'])
164
- end
165
-
166
- def test_DELETE_retrieves_the_response_headers
167
- assert_match(/text\/plain/, delete('echo').headers['content-type'])
168
- end
169
-
170
- def test_DELETE_retrieves_the_body
171
- assert_equal %(delete), delete('echo').body
172
- end
173
-
174
- def test_timeout
175
- conn = create_connection(:request => {:timeout => 1, :open_timeout => 1})
176
- assert_raises Faraday::Error::TimeoutError do
177
- conn.get '/slow'
178
- end
179
- end
180
-
181
- def test_connection_error
182
- assert_raises Faraday::Error::ConnectionFailed do
183
- get 'http://localhost:4'
184
- end
185
- end
186
-
187
- def test_proxy
188
- proxy_uri = URI(ENV['LIVE_PROXY'])
189
- conn = create_connection(:proxy => proxy_uri)
190
-
191
- res = conn.get '/echo'
192
- assert_equal 'get', res.body
193
-
194
- unless self.class.ssl_mode?
195
- # proxy can't append "Via" header for HTTPS responses
196
- assert_match(/:#{proxy_uri.port}$/, res['via'])
197
- end
198
- end
199
-
200
- def test_proxy_auth_fail
201
- proxy_uri = URI(ENV['LIVE_PROXY'])
202
- proxy_uri.password = 'WRONG'
203
- conn = create_connection(:proxy => proxy_uri)
204
-
205
- err = assert_raises Faraday::Error::ConnectionFailed do
206
- conn.get '/echo'
207
- end
208
-
209
- unless self.class.ssl_mode? && self.class.jruby?
210
- # JRuby raises "End of file reached" which cannot be distinguished from a 407
211
- assert_equal %{407 "Proxy Authentication Required "}, err.message
212
- end
213
- end
214
-
215
- def test_empty_body_response_represented_as_blank_string
216
- response = get('204')
217
- assert_equal '', response.body
218
- end
219
-
220
- def adapter
221
- raise NotImplementedError.new("Need to override #adapter")
222
- end
223
-
224
- # extra options to pass when building the adapter
225
- def adapter_options
226
- []
227
- end
228
-
229
- def create_connection(options = {})
230
- if adapter == :default
231
- builder_block = nil
232
- else
233
- builder_block = Proc.new do |b|
234
- b.request :multipart
235
- b.request :url_encoded
236
- b.adapter adapter, *adapter_options
237
- end
238
- end
239
-
240
- server = self.class.live_server
241
- url = '%s://%s:%d' % [server.scheme, server.host, server.port]
242
-
243
- options[:ssl] ||= {}
244
- options[:ssl][:ca_file] ||= ENV['SSL_FILE']
245
-
246
- Faraday::Connection.new(url, options, &builder_block).tap do |conn|
247
- conn.headers['X-Faraday-Adapter'] = adapter.to_s
248
- adapter_handler = conn.builder.handlers.last
249
- conn.builder.insert_before adapter_handler, Faraday::Response::RaiseError
250
- end
251
- end
252
- end
253
- end
254
- end
@@ -1,82 +0,0 @@
1
- require File.expand_path('../../helper', __FILE__)
2
- require 'stringio'
3
- require 'logger'
4
-
5
- module Adapters
6
- class LoggerTest < Faraday::TestCase
7
- def conn(logger, logger_options={})
8
- rubbles = ['Barney', 'Betty', 'Bam Bam']
9
-
10
- Faraday.new do |b|
11
- b.response :logger, logger, logger_options
12
- b.adapter :test do |stubs|
13
- stubs.get('/hello') { [200, {'Content-Type' => 'text/html'}, 'hello'] }
14
- stubs.post('/ohai') { [200, {'Content-Type' => 'text/html'}, 'fred'] }
15
- stubs.get('/ohno') { [200, {'Content-Type' => 'text/html'}, 'wilma'] }
16
- stubs.post('/ohyes') { [200, {'Content-Type' => 'text/html'}, 'pebbles'] }
17
- stubs.get('/rubbles') { [200, {'Content-Type' => 'application/json'}, rubbles] }
18
- end
19
- end
20
- end
21
-
22
- def setup
23
- @io = StringIO.new
24
- @logger = Logger.new(@io)
25
- @logger.level = Logger::DEBUG
26
-
27
- @conn = conn(@logger)
28
- @resp = @conn.get '/hello', nil, :accept => 'text/html'
29
- end
30
-
31
- def test_still_returns_output
32
- assert_equal 'hello', @resp.body
33
- end
34
-
35
- def test_logs_method_and_url
36
- assert_match "get http:/hello", @io.string
37
- end
38
-
39
- def test_logs_request_headers
40
- assert_match %(Accept: "text/html), @io.string
41
- end
42
-
43
- def test_logs_response_headers
44
- assert_match %(Content-Type: "text/html), @io.string
45
- end
46
-
47
- def test_does_not_log_request_body_by_default
48
- @conn.post '/ohai', 'name=Unagi', :accept => 'text/html'
49
- refute_match %(name=Unagi), @io.string
50
- end
51
-
52
- def test_does_not_log_response_body_by_default
53
- @conn.post '/ohai', 'name=Toro', :accept => 'text/html'
54
- refute_match %(fred), @io.string
55
- end
56
-
57
- def test_log_request_body
58
- app = conn(@logger, :bodies => { :request => true })
59
- app.post '/ohyes', 'name=Tamago', :accept => 'text/html'
60
- assert_match %(name=Tamago), @io.string
61
- end
62
-
63
- def test_log_response_body
64
- app = conn(@logger, :bodies => { :response => true })
65
- app.get '/ohno', :accept => 'text/html'
66
- assert_match %(wilma), @io.string
67
- end
68
-
69
- def test_log_request_and_response_body
70
- app = conn(@logger, :bodies => true)
71
- app.post '/ohyes', 'name=Ebi', :accept => 'text/html'
72
- assert_match %(name=Ebi), @io.string
73
- assert_match %(pebbles), @io.string
74
- end
75
-
76
- def test_log_response_body_object
77
- app = conn(@logger, :bodies => true)
78
- app.get '/rubbles', nil, :accept => 'text/html'
79
- assert_match %([\"Barney\", \"Betty\", \"Bam Bam\"]\n), @io.string
80
- end
81
- end
82
- end
@@ -1,20 +0,0 @@
1
- require File.expand_path('../integration', __FILE__)
2
-
3
- module Adapters
4
- class NetHttpPersistentTest < Faraday::TestCase
5
-
6
- def adapter() :net_http_persistent end
7
-
8
- Integration.apply(self, :NonParallel) do
9
- def setup
10
- if defined?(Net::HTTP::Persistent)
11
- # work around problems with mixed SSL certificates
12
- # https://github.com/drbrain/net-http-persistent/issues/45
13
- http = Net::HTTP::Persistent.new('Faraday')
14
- http.ssl_cleanup(4)
15
- end
16
- end if ssl_mode?
17
- end
18
-
19
- end
20
- end
@@ -1,14 +0,0 @@
1
- require File.expand_path('../integration', __FILE__)
2
-
3
- module Adapters
4
- class NetHttpTest < Faraday::TestCase
5
-
6
- def adapter() :net_http end
7
-
8
- behaviors = [:NonParallel]
9
- behaviors << :Compression if RUBY_VERSION >= '1.9'
10
-
11
- Integration.apply(self, *behaviors)
12
-
13
- end
14
- end
@@ -1,20 +0,0 @@
1
- require File.expand_path('../integration', __FILE__)
2
-
3
- module Adapters
4
- class Patron < Faraday::TestCase
5
-
6
- def adapter() :patron end
7
-
8
- Integration.apply(self, :NonParallel) do
9
- # https://github.com/toland/patron/issues/34
10
- undef :test_PATCH_send_url_encoded_params
11
-
12
- # https://github.com/toland/patron/issues/52
13
- undef :test_GET_with_body
14
-
15
- # no support for SSL peer verification
16
- undef :test_GET_ssl_fails_with_bad_cert if ssl_mode?
17
- end unless jruby?
18
-
19
- end
20
- end
@@ -1,31 +0,0 @@
1
- require File.expand_path("../integration", __FILE__)
2
- require File.expand_path('../../live_server', __FILE__)
3
-
4
- module Adapters
5
- class RackTest < Faraday::TestCase
6
-
7
- def adapter() :rack end
8
-
9
- def adapter_options
10
- [Faraday::LiveServer]
11
- end
12
-
13
- # no Integration.apply because this doesn't require a server as a separate process
14
- include Integration::Common
15
- include Integration::NonParallel
16
-
17
- # not using shared test because error is swallowed by Sinatra
18
- def test_timeout
19
- conn = create_connection(:request => {:timeout => 1, :open_timeout => 1})
20
- begin
21
- conn.get '/slow'
22
- rescue Faraday::Error::ClientError
23
- end
24
- end
25
-
26
- # test not applicable
27
- undef test_connection_error
28
- undef test_proxy
29
- undef test_proxy_auth_fail
30
- end
31
- end