chore: RuboCop Style/StringLiteral

This commit is contained in:
Olle Jonsson 2019-02-25 23:11:57 +01:00
parent a4ee8a7704
commit 00765145a3
36 changed files with 99 additions and 99 deletions

View File

@ -4,7 +4,7 @@ require 'rake/testtask'
task :default => :test
desc "Run all tests"
desc 'Run all tests'
task :test do
exec 'rspec'
end

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
lib = "faraday"
lib = 'faraday'
lib_file = File.expand_path("../lib/#{lib}.rb", __FILE__)
File.read(lib_file) =~ /\bVERSION\s*=\s*["'](.+?)["']/
version = $1
@ -9,9 +9,9 @@ Gem::Specification.new do |spec|
spec.name = lib
spec.version = version
spec.summary = "HTTP/REST API client library."
spec.summary = 'HTTP/REST API client library.'
spec.authors = ["Rick Olson"]
spec.authors = ['Rick Olson']
spec.email = 'technoweenie@gmail.com'
spec.homepage = 'https://github.com/lostisland/faraday'
spec.licenses = ['MIT']

View File

@ -20,7 +20,7 @@ require 'faraday/dependency_loader'
# conn.get '/'
#
module Faraday
VERSION = "0.15.3"
VERSION = '0.15.3'
METHODS_WITH_QUERY = %w[get head delete connect trace]
METHODS_WITH_BODY = %w[post put patch]
@ -116,8 +116,8 @@ module Faraday
end
self.ignore_env_proxy = false
self.root_path = File.expand_path "..", __FILE__
self.lib_path = File.expand_path "../faraday", __FILE__
self.root_path = File.expand_path '..', __FILE__
self.lib_path = File.expand_path '../faraday', __FILE__
self.default_adapter = :net_http
# @overload default_connection
@ -151,10 +151,10 @@ module Faraday
Timer = Timeout
end
require_libs "utils", "options", "connection", "rack_builder", "parameters",
"middleware", "adapter", "request", "response", "upload_io", "error"
require_libs 'utils', 'options', 'connection', 'rack_builder', 'parameters',
'middleware', 'adapter', 'request', 'response', 'upload_io', 'error'
if !ENV["FARADAY_NO_AUTOLOAD"]
if !ENV['FARADAY_NO_AUTOLOAD']
require_lib 'autoload'
end
end

View File

@ -132,7 +132,7 @@ module Faraday
end
end
rescue EventMachine::Connectify::CONNECTError => err
if err.message.include?("Proxy Authentication Required")
if err.message.include?('Proxy Authentication Required')
raise Faraday::ConnectionFailed, %{407 "Proxy Authentication Required "}
else
raise Faraday::ConnectionFailed, err
@ -168,18 +168,18 @@ module Faraday
end
def error_message(client)
client.error or "request failed"
client.error or 'request failed'
end
def raise_error(msg)
errklass = Faraday::ClientError
if msg == Errno::ETIMEDOUT
errklass = Faraday::TimeoutError
msg = "request timed out"
msg = 'request timed out'
elsif msg == Errno::ECONNREFUSED
errklass = Faraday::ConnectionFailed
msg = "connection refused"
elsif msg == "connection closed by server"
msg = 'connection refused'
elsif msg == 'connection closed by server'
errklass = Faraday::ConnectionFailed
end
raise errklass, msg
@ -228,7 +228,7 @@ module Faraday
end
end
if !@errors.empty?
raise Faraday::ClientError, @errors.first || "connection failed"
raise Faraday::ClientError, @errors.first || 'connection failed'
end
end
ensure
@ -254,7 +254,7 @@ end
begin
require 'openssl'
rescue LoadError
warn "Warning: no such file to load -- openssl. Make sure it is installed if you want HTTPS support"
warn 'Warning: no such file to load -- openssl. Make sure it is installed if you want HTTPS support'
else
require 'faraday/adapter/em_http_ssl_patch'
end if Faraday::Adapter::EMHttp.loaded?

View File

@ -80,7 +80,7 @@ module Faraday
rescue Errno::ECONNREFUSED
raise Faraday::ConnectionFailed, $!
rescue EventMachine::Connectify::CONNECTError => err
if err.message.include?("Proxy Authentication Required")
if err.message.include?('Proxy Authentication Required')
raise Faraday::ConnectionFailed, %{407 "Proxy Authentication Required "}
else
raise Faraday::ConnectionFailed, err
@ -88,7 +88,7 @@ module Faraday
rescue Errno::ETIMEDOUT => err
raise Faraday::TimeoutError, err
rescue RuntimeError => err
if err.message == "connection closed by server"
if err.message == 'connection closed by server'
raise Faraday::ConnectionFailed, err
else
raise
@ -113,7 +113,7 @@ require 'faraday/adapter/em_synchrony/parallel_manager'
begin
require 'openssl'
rescue LoadError
warn "Warning: no such file to load -- openssl. Make sure it is installed if you want HTTPS support"
warn 'Warning: no such file to load -- openssl. Make sure it is installed if you want HTTPS support'
else
require 'faraday/adapter/em_http_ssl_patch'
end if Faraday::Adapter::EMSynchrony.loaded?

View File

@ -3,7 +3,7 @@
begin
require 'net/https'
rescue LoadError
warn "Warning: no such file to load -- net/https. Make sure openssl is installed if you want ssl support"
warn 'Warning: no such file to load -- net/https. Make sure openssl is installed if you want ssl support'
require 'net/http'
end
require 'zlib'
@ -93,7 +93,7 @@ module Faraday
env[:request].on_data.call(chunk, size)
end
end
env[:request].on_data.call("", 0) unless yielded
env[:request].on_data.call('', 0) unless yielded
# Net::HTTP returns something, but it's not meaningful according to the docs.
http_response.body = nil
http_response

View File

@ -51,7 +51,7 @@ module Faraday
raise Faraday::TimeoutError, err
end
rescue ::Patron::Error => err
if err.message.include?("code 407")
if err.message.include?('code 407')
raise Faraday::ConnectionFailed, %{407 "Proxy Authentication Required "}
else
raise Faraday::ConnectionFailed, err
@ -67,8 +67,8 @@ module Faraday
actions << :options unless actions.include? :options
else
# Patron 0.4.20 and up
actions << "PATCH" unless actions.include? "PATCH"
actions << "OPTIONS" unless actions.include? "OPTIONS"
actions << 'PATCH' unless actions.include? 'PATCH'
actions << 'OPTIONS' unless actions.include? 'OPTIONS'
end
end
end
@ -84,14 +84,14 @@ module Faraday
private
CURL_TIMEOUT_MESSAGES = [
"Connection time-out",
"Connection timed out",
"Timed out before name resolve",
"server connect has timed out",
"Resolving timed out",
"name lookup timed out",
"timed out before SSL",
"connect() timed out"
'Connection time-out',
'Connection timed out',
'Timed out before name resolve',
'server connect has timed out',
'Resolving timed out',
'name lookup timed out',
'timed out before SSL',
'connect() timed out'
].freeze
def connection_timed_out_message?(message)

View File

@ -107,7 +107,7 @@ module Faraday
})
end
end
raise failed_stubs.join(" ") unless failed_stubs.empty?
raise failed_stubs.join(' ') unless failed_stubs.empty?
end
protected
@ -134,7 +134,7 @@ module Faraday
class Stub < Struct.new(:host, :path, :params, :headers, :body, :block)
def initialize(host, full, headers, body, block)
path, query = full.respond_to?(:split) ? full.split("?") : full
path, query = full.respond_to?(:split) ? full.split('?') : full
params = query ?
Faraday::Utils.parse_nested_query(query) :
{}

View File

@ -367,7 +367,7 @@ module Faraday
# @return [void]
def in_parallel(manager = nil)
@parallel_manager = manager || default_parallel_manager {
warn "Warning: `in_parallel` called but no parallel-capable adapter on Faraday stack"
warn 'Warning: `in_parallel` called but no parallel-capable adapter on Faraday stack'
warn caller[2,10].join("\n")
nil
}

View File

@ -26,7 +26,7 @@ module Faraday
end
# The params have form [['key1', 'value1'], ['key2', 'value2']].
buffer = +""
buffer = +''
params.each do |key, value|
encoded_key = escape(key)
value = value.to_s if value == true || value == false
@ -56,7 +56,7 @@ module Faraday
pair[0] = unescape(pair[0])
pair[1] = true if pair[1].nil?
if pair[1].respond_to?(:to_str)
pair[1] = unescape(pair[1].to_str.gsub(/\+/, " "))
pair[1] = unescape(pair[1].to_str.gsub(/\+/, ' '))
end
if accu[pair[0]].kind_of?(Array)
accu[pair[0]] << pair[1]

View File

@ -41,7 +41,7 @@ module Faraday
[key, val]
end
value.sort!
buffer = +""
buffer = +''
value.each do |key, val|
new_parent = "#{parent}%5B#{key}%5D"
buffer << "#{to_query.call(new_parent, val)}&"
@ -51,7 +51,7 @@ module Faraday
new_parent = "#{parent}%5B%5D"
return new_parent if value.empty?
buffer = +""
buffer = +''
value.each_with_index do |val, i|
buffer << "#{to_query.call(new_parent, val)}&"
end
@ -65,7 +65,7 @@ module Faraday
end
# The params have form [['key1', 'value1'], ['key2', 'value2']].
buffer = +""
buffer = +''
params.each do |parent, value|
encoded_parent = escape(parent)
buffer << "#{to_query.call(encoded_parent, value)}&"
@ -82,10 +82,10 @@ module Faraday
return nil if query == nil
params = {}
query.split("&").each do |pair|
query.split('&').each do |pair|
next if pair.empty?
key, value = pair.split("=", 2)
key, value = pair.split('=', 2)
key = unescape(key)
value = unescape(value.gsub(/\+/, ' ')) if value

View File

@ -29,7 +29,7 @@ module Faraday
end
def inspect
inner = +""
inner = +''
if @wrapped_exception
inner << " wrapped=#{@wrapped_exception.inspect}"
end

View File

@ -147,7 +147,7 @@ module Faraday
value = send(member)
values << "#{member}=#{value.inspect}" if value
end
values = values.empty? ? ' (empty)' : (' ' << values.join(", "))
values = values.empty? ? ' (empty)' : (' ' << values.join(', '))
%(#<#{self.class}#{values}>)
end

View File

@ -211,7 +211,7 @@ module Faraday
end
def raise_if_adapter(klass)
raise "Adapter should be set using the `adapter` method, not `use`" if is_adapter?(klass)
raise 'Adapter should be set using the `adapter` method, not `use`' if is_adapter?(klass)
end
def adapter_set?

View File

@ -3,7 +3,7 @@
module Faraday
# Request middleware for the Authorization HTTP header
class Request::Authorization < Faraday::Middleware
KEY = "Authorization" unless defined? KEY
KEY = 'Authorization' unless defined? KEY
# @param type [String, Symbol]
# @param token [String, Symbol, Hash]
@ -24,7 +24,7 @@ module Faraday
# @return [String] type followed by comma-separated key=value pairs
# @api private
def self.build_hash(type, hash)
comma = ", "
comma = ', '
values = []
hash.each do |key, value|
values << "#{key}=#{value.to_s.inspect}"

View File

@ -1,13 +1,13 @@
# frozen_string_literal: true
require File.expand_path("../url_encoded", __FILE__)
require File.expand_path('../url_encoded', __FILE__)
require 'securerandom'
module Faraday
# Middleware for supporting multi-part requests.
class Request::Multipart < Request::UrlEncoded
self.mime_type = 'multipart/form-data'
DEFAULT_BOUNDARY_PREFIX = "-----------RubyMultipartPost" unless defined? DEFAULT_BOUNDARY_PREFIX
DEFAULT_BOUNDARY_PREFIX = '-----------RubyMultipartPost' unless defined? DEFAULT_BOUNDARY_PREFIX
# Checks for files in the payload, otherwise leaves everything untouched.
#

View File

@ -190,7 +190,7 @@ module Faraday
response_headers = env[:response_headers]
return unless response_headers
retry_after_value = env[:response_headers]["Retry-After"]
retry_after_value = env[:response_headers]['Retry-After']
# Try to parse date from the header value
begin

View File

@ -64,7 +64,7 @@ module Faraday
end
def finish(env)
raise "response already finished" if finished?
raise 'response already finished' if finished?
@env = env.is_a?(Env) ? env : Env.from(env)
@on_complete_callbacks.each { |callback| callback.call(@env) }

View File

@ -5,7 +5,7 @@ begin
require 'parts'
require 'stringio'
rescue LoadError
$stderr.puts "Install the multipart-post gem."
$stderr.puts 'Install the multipart-post gem.'
raise
end
@ -37,12 +37,12 @@ module Faraday
# @param outbuf [String, nil]
def read(length = nil, outbuf = nil)
got_result = false
outbuf = outbuf ? (+outbuf).replace("") : +""
outbuf = outbuf ? (+outbuf).replace('') : +''
while (io = current_io)
if (result = io.read(length))
got_result ||= !result.nil?
result.force_encoding("BINARY") if result.respond_to?(:force_encoding)
result.force_encoding('BINARY') if result.respond_to?(:force_encoding)
outbuf << result
length -= result.length if length
break if length == 0

View File

@ -57,7 +57,7 @@ module Faraday
elsif url.respond_to?(:to_str)
default_uri_parser.call(url)
else
raise ArgumentError, "bad argument (expected URI object or URI string)"
raise ArgumentError, 'bad argument (expected URI object or URI string)'
end
end
@ -80,7 +80,7 @@ module Faraday
def normalize_path(url)
url = URI(url)
(url.path.start_with?('/') ? url.path : '/' + url.path) +
(url.query ? "?#{sort_query_params(url.query)}" : "")
(url.query ? "?#{sort_query_params(url.query)}" : '')
end
# Recursive hash update

View File

@ -47,7 +47,7 @@ module Faraday
end
keymap_mutex.synchronize { map[key] = value }
end
KeyMap[:etag] = "ETag"
KeyMap[:etag] = 'ETag'
def [](k)
k = KeyMap[k]

View File

@ -15,7 +15,7 @@ if (found = ARGV.index('-u'))
end
match_credentials = lambda { |credentials|
got_username, got_password = credentials.to_s.unpack("m*")[0].split(":", 2)
got_username, got_password = credentials.to_s.unpack('m*')[0].split(':', 2)
got_username == username && got_password == password
}
@ -24,11 +24,11 @@ log_io.sync = true
webrick_opts = {
:Port => port, :Logger => WEBrick::Log::new(log_io),
:AccessLog => [[log_io, "[%{X-Faraday-Adapter}i] %m %U -> %s %b"]],
:AccessLog => [[log_io, '[%{X-Faraday-Adapter}i] %m %U -> %s %b']],
:ProxyAuthProc => lambda { |req, res|
if username
type, credentials = req.header['proxy-authorization'].first.to_s.split(/\s+/, 2)
unless "Basic" == type && match_credentials.call(credentials)
unless 'Basic' == type && match_credentials.call(credentials)
res['proxy-authenticate'] = %{Basic realm="testing"}
raise WEBrick::HTTPStatus::ProxyAuthenticationRequired
end

View File

@ -19,7 +19,7 @@ log_io.sync = true
webrick_opts = {
:Port => port, :Logger => WEBrick::Log::new(log_io),
:AccessLog => [[log_io, "[%{X-Faraday-Adapter}i] %m %U -> %s %b"]]
:AccessLog => [[log_io, '[%{X-Faraday-Adapter}i] %m %U -> %s %b']]
}
if ENV['SSL_KEY']

View File

@ -67,13 +67,13 @@ RSpec.describe Faraday::CompositeReadIO do
end
context 'with utf8 multibyte part' do
subject { composite_io(part("\x86"), part("ファイル")) }
subject { composite_io(part("\x86"), part('ファイル')) }
it { expect(subject.read).to eq(String.new("\x86\xE3\x83\x95\xE3\x82\xA1\xE3\x82\xA4\xE3\x83\xAB", encoding: "BINARY"))}
it { expect(subject.read).to eq(String.new("\x86\xE3\x83\x95\xE3\x82\xA1\xE3\x82\xA4\xE3\x83\xAB", encoding: 'BINARY'))}
it 'allows to read in chunks' do
expect(subject.read(3)).to eq(String.new("\x86\xE3\x83", encoding: "BINARY"))
expect(subject.read(3)).to eq(String.new("\x95\xE3\x82", encoding: "BINARY"))
expect(subject.read(8)).to eq(String.new("\xA1\xE3\x82\xA4\xE3\x83\xAB", encoding: "BINARY"))
expect(subject.read(3)).to eq(String.new("\x86\xE3\x83", encoding: 'BINARY'))
expect(subject.read(3)).to eq(String.new("\x95\xE3\x82", encoding: 'BINARY'))
expect(subject.read(8)).to eq(String.new("\xA1\xE3\x82\xA4\xE3\x83\xAB", encoding: 'BINARY'))
expect(subject.read(3)).to be_nil
end
end

View File

@ -28,12 +28,12 @@ RSpec.describe Faraday::Env do
end
it 'retains custom members' do
env[:foo] = "custom 1"
env[:foo] = 'custom 1'
env[:bar] = :custom_2
env2 = Faraday::Env.from(env)
env2[:baz] = "custom 3"
env2[:baz] = 'custom 3'
expect(env2[:foo]).to eq("custom 1")
expect(env2[:foo]).to eq('custom 1')
expect(env2[:bar]).to eq(:custom_2)
expect(env[:baz]).to be_nil
end

View File

@ -13,7 +13,7 @@ RSpec.describe Faraday::NestedParamsEncoder do
it 'decodes hashes' do
query = 'a[b1]=one&a[b2]=two&a[b][c]=foo'
expected = { "a" => { "b1" => "one", "b2" => "two", "b" => { "c" => "foo" } } }
expected = { 'a' => { 'b1' => 'one', 'b2' => 'two', 'b' => { 'c' => 'foo' } } }
expect(subject.decode(query)).to eq(expected)
end
@ -31,13 +31,13 @@ RSpec.describe Faraday::NestedParamsEncoder do
it 'decodes nested ignores invalid array' do
query = '[][a]=1&b=2'
expected = { "a" => "1", "b" => "2" }
expected = { 'a' => '1', 'b' => '2' }
expect(subject.decode(query)).to eq(expected)
end
it 'decodes nested ignores repeated array notation' do
query = 'a[][][]=1'
expected = { "a" => ["1"] }
expected = { 'a' => ['1'] }
expect(subject.decode(query)).to eq(expected)
end
@ -49,18 +49,18 @@ RSpec.describe Faraday::NestedParamsEncoder do
it 'decodes nested subkeys dont have to be in brackets' do
query = 'a[b]c[d]e=1'
expected = { "a" => { "b" => { "c" => { "d" => { "e" => "1" } } } } }
expected = { 'a' => { 'b' => { 'c' => { 'd' => { 'e' => '1' } } } } }
expect(subject.decode(query)).to eq(expected)
end
it 'decodes nested final value overrides any type' do
query = 'a[b][c]=1&a[b]=2'
expected = { "a" => { "b" => "2" } }
expected = { 'a' => { 'b' => '2' } }
expect(subject.decode(query)).to eq(expected)
end
it 'encodes rack compat' do
params = { :a => [{ :one => "1", :two => "2" }, "3", ""] }
params = { :a => [{ :one => '1', :two => '2' }, '3', ''] }
result = Faraday::Utils.unescape(Faraday::NestedParamsEncoder.encode(params)).split('&')
expected = Rack::Utils.build_nested_query(params).split('&')
expect(result).to match_array(expected)

View File

@ -21,7 +21,7 @@ RSpec.describe Faraday::Request::Multipart do
response = conn.post('/echo', payload)
expect(response.body).to be_a_kind_of(Faraday::CompositeReadIO)
match = "multipart/form-data; boundary=%s" % Faraday::Request::Multipart::DEFAULT_BOUNDARY_PREFIX
match = 'multipart/form-data; boundary=%s' % Faraday::Request::Multipart::DEFAULT_BOUNDARY_PREFIX
expect(response.headers['Content-Type']).to start_with(match)
response.body.send(:ios).map { |io| io.read }.each do |io|

View File

@ -171,7 +171,7 @@ RSpec.describe Faraday::Request::Retry do
let(:options) { [{ retry_if: @check, methods: [:post] }] }
it 'does not call retry_if for specified methods' do
@check = lambda { |_, _| raise "this should have never been called" }
@check = lambda { |_, _| raise 'this should have never been called' }
expect { conn.post('/unstable') }.to raise_error(Errno::ETIMEDOUT)
expect(times_called).to eq(3)
end

View File

@ -57,7 +57,7 @@ RSpec.describe Faraday::Request::UrlEncoded do
it 'works with unicode' do
err = capture_warnings {
response = conn.post('/echo', {:str => "eé cç aã aâ"})
response = conn.post('/echo', {:str => 'eé cç aã aâ'})
expect(response.body).to eq('str=e%C3%A9+c%C3%A7+a%C3%A3+a%C3%A2')
}
expect(err.empty?).to be_truthy
@ -65,6 +65,6 @@ RSpec.describe Faraday::Request::UrlEncoded do
it 'works with nested keys' do
response = conn.post('/echo', {'a'=>{'b'=>{'c'=>['d']}}})
expect(response.body).to eq("a%5Bb%5D%5Bc%5D%5B%5D=d")
expect(response.body).to eq('a%5Bb%5D%5Bc%5D%5B%5D=d')
end
end

View File

@ -40,7 +40,7 @@ RSpec.describe Faraday::Response::Logger do
it 'logs method and url' do
conn.get '/hello', nil, accept: 'text/html'
expect(string_io.string).to match("GET http:/hello")
expect(string_io.string).to match('GET http:/hello')
end
it 'logs request headers by default' do

View File

@ -13,12 +13,12 @@ RSpec.describe Faraday::Utils do
result = headers.to_hash
expect(result["Content-Type"]).to eq("application/json; charset=UTF-8")
expect(result['Content-Type']).to eq('application/json; charset=UTF-8')
end
end
describe 'URI parsing' do
let(:url) { "http://example.com/abc" }
let(:url) { 'http://example.com/abc' }
it 'escapes safe buffer' do
str = FakeSafeBuffer.new('$32,000.00')

View File

@ -48,7 +48,7 @@ shared_examples 'a request method' do |http_method|
on_feature :request_body_on_query_methods do
it 'sends request body' do
request_stub.with(Hash[:body, "test"])
request_stub.with(Hash[:body, 'test'])
res = if query_or_body == :body
conn.public_send(http_method, '/', 'test')
else
@ -99,7 +99,7 @@ shared_examples 'a request method' do |http_method|
if method_with_body?(http_method)
it 'sends files' do
payload = { uploaded_file: multipart_file }
request_stub.with(headers: { "Content-Type" => %r[\Amultipart/form-data] }) do |request|
request_stub.with(headers: { 'Content-Type' => %r[\Amultipart/form-data] }) do |request|
# WebMock does not support matching body for multipart/form-data requests yet :(
# https://github.com/bblimke/webmock/issues/623
request.body =~ %r[RubyMultipartPost]
@ -140,7 +140,7 @@ shared_examples 'a request method' do |http_method|
req.options.on_data = Proc.new { |*args| streamed << args }
end
expect(streamed).to eq([["", 0]])
expect(streamed).to eq([['', 0]])
end
end

View File

@ -1,8 +1,8 @@
# frozen_string_literal: true
require 'forwardable'
require File.expand_path("../../helper", __FILE__)
require File.expand_path("../../shared", __FILE__)
require File.expand_path('../../helper', __FILE__)
require File.expand_path('../../shared', __FILE__)
Faraday.require_lib 'autoload'
module Adapters
@ -19,9 +19,9 @@ module Adapters
features.each { |name| base.send(:include, self.const_get(name)) }
yield if block_given?
elsif !defined? @warned
warn "Warning: Not running integration tests against a live server."
warn "Start the server `ruby test/live_server.rb` and set the LIVE=1 env variable."
warn "See CONTRIBUTING for usage."
warn 'Warning: Not running integration tests against a live server.'
warn 'Start the server `ruby test/live_server.rb` and set the LIVE=1 env variable.'
warn 'See CONTRIBUTING for usage.'
@warned = true
end
end
@ -37,7 +37,7 @@ module Adapters
end
end
assert response
assert_match "no parallel-capable adapter on Faraday stack", err
assert_match 'no parallel-capable adapter on Faraday stack', err
assert_match __FILE__, err
end
end
@ -100,7 +100,7 @@ module Adapters
err = assert_raises Faraday::SSLError do
conn.get('/ssl')
end
assert_includes err.message, "certificate"
assert_includes err.message, 'certificate'
end
end
@ -109,7 +109,7 @@ module Adapters
def_delegators :create_connection, :get, :head, :put, :post, :patch, :delete, :run_request
def adapter
raise NotImplementedError.new("Need to override #adapter")
raise NotImplementedError.new('Need to override #adapter')
end
# extra options to pass when building the adapter

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
require File.expand_path("../integration", __FILE__)
require File.expand_path('../integration', __FILE__)
require File.expand_path('../../live_server', __FILE__)
module Adapters

View File

@ -91,8 +91,8 @@ module Adapters
def test_middleware_allow_different_outcomes_for_the_same_request
@stubs.get('/hello') { [200, {'Content-Type' => 'text/html'}, 'hello'] }
@stubs.get('/hello') { [200, {'Content-Type' => 'text/html'}, 'world'] }
assert_equal 'hello', @conn.get("/hello").body
assert_equal 'world', @conn.get("/hello").body
assert_equal 'hello', @conn.get('/hello').body
assert_equal 'world', @conn.get('/hello').body
end
def test_yields_env_to_stubs

View File

@ -36,7 +36,7 @@ module Faraday
send(method, '/empty_stream') do
content_type :txt
stream do |out|
out << ""
out << ''
end
end
end
@ -48,7 +48,7 @@ module Faraday
post '/file' do
if params[:uploaded_file].respond_to? :each_key
"file %s %s %d" % [
'file %s %s %d' % [
params[:uploaded_file][:filename],
params[:uploaded_file][:type],
params[:uploaded_file][:tempfile].size