diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e49fd534..c6bc5af2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2019-02-26 21:39:01 +0100 using RuboCop version 0.65.0. +# on 2019-02-27 08:43:56 +0100 using RuboCop version 0.65.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -15,15 +15,6 @@ Layout/EndAlignment: - 'lib/faraday/connection.rb' - 'test/helper.rb' -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. -Layout/ExtraSpacing: - Exclude: - - 'lib/faraday/adapter/net_http.rb' - - 'lib/faraday/connection.rb' - - 'test/adapters/test_middleware_test.rb' - # Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. @@ -46,103 +37,6 @@ Layout/RescueEnsureAlignment: Exclude: - 'lib/faraday/adapter/patron.rb' -# Offense count: 5 -# Cop supports --auto-correct. -Layout/SpaceAfterComma: - Exclude: - - 'lib/faraday/connection.rb' - - 'lib/faraday/request/multipart.rb' - - 'lib/faraday/request/retry.rb' - - 'spec/faraday/connection_spec.rb' - -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, no_space -Layout/SpaceAroundEqualsInParameterDefault: - Exclude: - - 'lib/faraday/adapter/test.rb' - -# Offense count: 12 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment. -Layout/SpaceAroundOperators: - Exclude: - - 'lib/faraday/adapter/net_http.rb' - - 'lib/faraday/request/retry.rb' - - 'script/generate_certs' - - 'spec/faraday/request/url_encoded_spec.rb' - - 'spec/support/helper_methods.rb' - - 'test/adapters/test_middleware_test.rb' - - 'test/shared.rb' - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceBeforeBlockBraces: - Exclude: - - 'spec/support/helper_methods.rb' - - 'test/adapters/test_middleware_test.rb' - - 'test/shared.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBrackets: space, no_space -Layout/SpaceInsideArrayLiteralBrackets: - Exclude: - - 'lib/faraday/response/logger.rb' - -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideBlockBraces: - Exclude: - - 'lib/faraday/adapter/test.rb' - - 'lib/faraday/utils.rb' - - 'script/generate_certs' - - 'spec/faraday/composite_read_io_spec.rb' - - 'spec/faraday/utils_spec.rb' - - 'spec/support/helper_methods.rb' - - 'test/shared.rb' - -# Offense count: 52 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideHashLiteralBraces: - Exclude: - - 'lib/faraday/adapter/net_http_persistent.rb' - - 'lib/faraday/options/proxy_options.rb' - - 'lib/faraday/response/raise_error.rb' - - 'spec/faraday/params_encoders/flat_spec.rb' - - 'spec/faraday/params_encoders/nested_spec.rb' - - 'spec/faraday/request/url_encoded_spec.rb' - - 'spec/faraday/utils_spec.rb' - - 'test/adapters/rack_test.rb' - - 'test/adapters/test_middleware_test.rb' - -# Offense count: 10 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, no_space -Layout/SpaceInsideParens: - Exclude: - - 'lib/faraday/adapter/excon.rb' - - 'lib/faraday/response/logger.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -Layout/SpaceInsidePercentLiteralDelimiters: - Exclude: - - 'lib/faraday/adapter/rack.rb' - # Offense count: 1 Lint/HandleExceptions: Exclude: @@ -913,7 +807,7 @@ Style/YodaCondition: - 'script/proxy-server' - 'test/helper.rb' -# Offense count: 272 +# Offense count: 273 # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Metrics/LineLength: diff --git a/lib/faraday/adapter/excon.rb b/lib/faraday/adapter/excon.rb index 2f39f3ef..421052be 100644 --- a/lib/faraday/adapter/excon.rb +++ b/lib/faraday/adapter/excon.rb @@ -27,7 +27,7 @@ module Faraday opts[:nonblock] = false end - if ( req = env[:request] ) + if (req = env[:request]) if req[:timeout] opts[:read_timeout] = req[:timeout] opts[:connect_timeout] = req[:timeout] diff --git a/lib/faraday/adapter/net_http.rb b/lib/faraday/adapter/net_http.rb index 1fac6dfb..8eac3ab3 100644 --- a/lib/faraday/adapter/net_http.rb +++ b/lib/faraday/adapter/net_http.rb @@ -161,7 +161,7 @@ module Faraday http.open_timeout = req[:open_timeout] if req[:open_timeout] http.write_timeout = req[:write_timeout] if req[:write_timeout] && http.respond_to?(:write_timeout=) # Only set if Net::Http supports it, since Ruby 2.5. - http.max_retries = 0 if http.respond_to?(:max_retries=) + http.max_retries = 0 if http.respond_to?(:max_retries=) @config_block.call(http) if @config_block end diff --git a/lib/faraday/adapter/net_http_persistent.rb b/lib/faraday/adapter/net_http_persistent.rb index 13b2bcb5..3035d89b 100644 --- a/lib/faraday/adapter/net_http_persistent.rb +++ b/lib/faraday/adapter/net_http_persistent.rb @@ -11,7 +11,7 @@ module Faraday def net_http_connection(env) @cached_connection ||= if Net::HTTP::Persistent.instance_method(:initialize).parameters.first == [:key, :name] - options = {name: 'Faraday'} + options = { name: 'Faraday' } options[:pool_size] = @connection_options[:pool_size] if @connection_options.key?(:pool_size) Net::HTTP::Persistent.new(options) else diff --git a/lib/faraday/adapter/rack.rb b/lib/faraday/adapter/rack.rb index 11f27323..378b49ea 100644 --- a/lib/faraday/adapter/rack.rb +++ b/lib/faraday/adapter/rack.rb @@ -19,7 +19,7 @@ module Faraday dependency 'rack/test' # not prefixed with "HTTP_" - SPECIAL_HEADERS = %w[ CONTENT_LENGTH CONTENT_TYPE ] + SPECIAL_HEADERS = %w[CONTENT_LENGTH CONTENT_TYPE] def initialize(faraday_app, rack_app) super(faraday_app) diff --git a/lib/faraday/adapter/test.rb b/lib/faraday/adapter/test.rb index 5504dfe5..e4c15bd6 100644 --- a/lib/faraday/adapter/test.rb +++ b/lib/faraday/adapter/test.rb @@ -77,15 +77,15 @@ module Faraday new_stub(:head, path, headers, &block) end - def post(path, body=nil, headers = {}, &block) + def post(path, body = nil, headers = {}, &block) new_stub(:post, path, headers, body, &block) end - def put(path, body=nil, headers = {}, &block) + def put(path, body = nil, headers = {}, &block) new_stub(:put, path, headers, body, &block) end - def patch(path, body=nil, headers = {}, &block) + def patch(path, body = nil, headers = {}, &block) new_stub(:patch, path, headers, body, &block) end @@ -102,7 +102,7 @@ module Faraday failed_stubs = [] @stack.each do |method, stubs| unless stubs.empty? - failed_stubs.concat(stubs.map {|stub| + failed_stubs.concat(stubs.map { |stub| "Expected #{method} #{stub}." }) end @@ -112,7 +112,7 @@ module Faraday protected - def new_stub(request_method, path, headers = {}, body=nil, &block) + def new_stub(request_method, path, headers = {}, body = nil, &block) normalized_path, host = if path.is_a?(Regexp) path @@ -181,7 +181,7 @@ module Faraday end end - def initialize(app, stubs=nil, &block) + def initialize(app, stubs = nil, &block) super(app) @stubs = stubs || Stubs.new configure(&block) if block diff --git a/lib/faraday/connection.rb b/lib/faraday/connection.rb index 80e55a64..3d3ede49 100644 --- a/lib/faraday/connection.rb +++ b/lib/faraday/connection.rb @@ -368,7 +368,7 @@ module Faraday 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 caller[2,10].join("\n") + warn caller[2, 10].join("\n") nil } yield @@ -428,7 +428,7 @@ module Faraday # @return [String] the new path prefix def path_prefix=(value) url_prefix.path = if value - value = '/' + value unless value[0,1] == '/' + value = '/' + value unless value[0, 1] == '/' value end end @@ -512,7 +512,7 @@ module Faraday base = url_prefix if url and base.path and base.path !~ /\/$/ base = base.dup - base.path = base.path + '/' # ensure trailing slash + base.path = base.path + '/' # ensure trailing slash end uri = url ? base + url : base uri.query = params.to_query(params_encoder || options.params_encoder) if params diff --git a/lib/faraday/options/proxy_options.rb b/lib/faraday/options/proxy_options.rb index 0c5b631a..5056c273 100644 --- a/lib/faraday/options/proxy_options.rb +++ b/lib/faraday/options/proxy_options.rb @@ -8,9 +8,9 @@ module Faraday def self.from(value) case value when String - value = {uri: Utils.URI(value)} + value = { uri: Utils.URI(value) } when URI - value = {uri: value} + value = { uri: value } when Hash, Options if (uri = value.delete(:uri)) value[:uri] = Utils.URI(uri) diff --git a/lib/faraday/request/multipart.rb b/lib/faraday/request/multipart.rb index 6a31d379..99061785 100644 --- a/lib/faraday/request/multipart.rb +++ b/lib/faraday/request/multipart.rb @@ -72,7 +72,7 @@ module Faraday case value when Array - values = value.inject([]) { |a,v| a << [nil, v] } + values = value.inject([]) { |a, v| a << [nil, v] } process_params(values, key, all, &block) when Hash process_params(value, key, all, &block) diff --git a/lib/faraday/request/retry.rb b/lib/faraday/request/retry.rb index 9facb69c..38b7659c 100644 --- a/lib/faraday/request/retry.rb +++ b/lib/faraday/request/retry.rb @@ -29,7 +29,7 @@ module Faraday :backoff_factor, :exceptions, :methods, :retry_if, :retry_block, :retry_statuses) - DEFAULT_CHECK = lambda { |env,exception| false } + DEFAULT_CHECK = lambda { |env, exception| false } def self.from(value) if Integer === value @@ -202,7 +202,7 @@ module Faraday def calculate_retry_interval(retries) retry_index = @options.max - retries - current_interval = @options.interval * (@options.backoff_factor ** retry_index) + current_interval = @options.interval * (@options.backoff_factor**retry_index) current_interval = [current_interval, @options.max_interval].min random_interval = rand * @options.interval_randomness.to_f * @options.interval diff --git a/lib/faraday/response/logger.rb b/lib/faraday/response/logger.rb index ea1d9ad0..6f66bcf2 100644 --- a/lib/faraday/response/logger.rb +++ b/lib/faraday/response/logger.rb @@ -23,19 +23,19 @@ module Faraday def call(env) info('request') { "#{env.method.upcase} #{apply_filters(env.url.to_s)}" } - debug('request') { apply_filters( dump_headers env.request_headers ) } if log_headers?(:request) - debug('request') { apply_filters( dump_body(env[:body]) ) } if env[:body] && log_body?(:request) + debug('request') { apply_filters(dump_headers env.request_headers) } if log_headers?(:request) + debug('request') { apply_filters(dump_body(env[:body])) } if env[:body] && log_body?(:request) super end def on_complete(env) info('response') { "Status #{env.status.to_s}" } - debug('response') { apply_filters( dump_headers env.response_headers ) } if log_headers?(:response) - debug('response') { apply_filters( dump_body env[:body] ) } if env[:body] && log_body?(:response) + debug('response') { apply_filters(dump_headers env.response_headers) } if log_headers?(:response) + debug('response') { apply_filters(dump_body env[:body]) } if env[:body] && log_body?(:response) end def filter(filter_word, filter_replacement) - @filter.push([ filter_word, filter_replacement ]) + @filter.push([filter_word, filter_replacement]) end private diff --git a/lib/faraday/response/raise_error.rb b/lib/faraday/response/raise_error.rb index 6292ab40..c6ac900b 100644 --- a/lib/faraday/response/raise_error.rb +++ b/lib/faraday/response/raise_error.rb @@ -28,7 +28,7 @@ module Faraday end def response_values(env) - {status: env.status, headers: env.response_headers, body: env.body} + { status: env.status, headers: env.response_headers, body: env.body } end end end diff --git a/lib/faraday/utils.rb b/lib/faraday/utils.rb index 6965f6d5..a1202df1 100644 --- a/lib/faraday/utils.rb +++ b/lib/faraday/utils.rb @@ -20,7 +20,7 @@ module Faraday ESCAPE_RE = /[^a-zA-Z0-9 .~_-]/ def escape(s) - s.to_s.gsub(ESCAPE_RE) {|match| + s.to_s.gsub(ESCAPE_RE) { |match| '%' + match.unpack('H2' * match.bytesize).join('%').upcase }.tr(' ', '+') end diff --git a/script/generate_certs b/script/generate_certs index f47997ca..ff10303b 100755 --- a/script/generate_certs +++ b/script/generate_certs @@ -20,7 +20,7 @@ def create_self_signed_cert(bits, cn, comment) cert.subject = name cert.issuer = name cert.not_before = Time.now - cert.not_after = Time.now + (365*24*60*60) + cert.not_after = Time.now + (365 * 24 * 60 * 60) cert.public_key = rsa.public_key cert.sign(rsa, OpenSSL::Digest::SHA1.new) return [cert, rsa] @@ -28,7 +28,7 @@ end def write(file, contents, env_var) FileUtils.mkdir_p(File.dirname(file)) - File.open(file, 'w') {|f| f.puts(contents) } + File.open(file, 'w') { |f| f.puts(contents) } puts %(export #{env_var}="#{file}") if $shell end diff --git a/spec/faraday/composite_read_io_spec.rb b/spec/faraday/composite_read_io_spec.rb index 9575ecd0..ccba34f3 100644 --- a/spec/faraday/composite_read_io_spec.rb +++ b/spec/faraday/composite_read_io_spec.rb @@ -69,7 +69,7 @@ RSpec.describe Faraday::CompositeReadIO do context 'with utf8 multibyte part' do 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')) diff --git a/spec/faraday/connection_spec.rb b/spec/faraday/connection_spec.rb index 27f246ae..b3a23b1d 100644 --- a/spec/faraday/connection_spec.rb +++ b/spec/faraday/connection_spec.rb @@ -602,7 +602,7 @@ RSpec.describe Faraday::Connection do it 'allows to set params_encoder for single request' do encoder = Object.new def encoder.encode(params) - params.map { |k,v| "#{k.upcase}-#{v.to_s.upcase}" }.join(',') + params.map { |k, v| "#{k.upcase}-#{v.to_s.upcase}" }.join(',') end stubbed = stub_request(:get, 'http://example.com/?A-1,B-2,C-3,FEELING-BLUE') diff --git a/spec/faraday/params_encoders/flat_spec.rb b/spec/faraday/params_encoders/flat_spec.rb index 93a8c6c7..7e735762 100644 --- a/spec/faraday/params_encoders/flat_spec.rb +++ b/spec/faraday/params_encoders/flat_spec.rb @@ -7,7 +7,7 @@ RSpec.describe Faraday::FlatParamsEncoder do it 'decodes arrays' do query = 'a=one&a=two&a=three' - expected = {'a' => %w(one two three) } + expected = { 'a' => %w(one two three) } expect(subject.decode(query)).to eq(expected) end end diff --git a/spec/faraday/params_encoders/nested_spec.rb b/spec/faraday/params_encoders/nested_spec.rb index 46c30b01..aaeb0521 100644 --- a/spec/faraday/params_encoders/nested_spec.rb +++ b/spec/faraday/params_encoders/nested_spec.rb @@ -68,13 +68,13 @@ RSpec.describe Faraday::NestedParamsEncoder do it 'encodes empty string array value' do expected = 'baz=&foo%5Bbar%5D=' - result = Faraday::NestedParamsEncoder.encode(foo: {bar: ''}, baz: '') + result = Faraday::NestedParamsEncoder.encode(foo: { bar: '' }, baz: '') expect(result).to eq(expected) end it 'encodes nil array value' do expected = 'baz&foo%5Bbar%5D' - result = Faraday::NestedParamsEncoder.encode(foo: {bar: nil}, baz: nil) + result = Faraday::NestedParamsEncoder.encode(foo: { bar: nil }, baz: nil) expect(result).to eq(expected) end diff --git a/spec/faraday/request/url_encoded_spec.rb b/spec/faraday/request/url_encoded_spec.rb index cb03524e..d0dbe716 100644 --- a/spec/faraday/request/url_encoded_spec.rb +++ b/spec/faraday/request/url_encoded_spec.rb @@ -8,7 +8,7 @@ RSpec.describe Faraday::Request::UrlEncoded do b.adapter :test do |stub| stub.post('/echo') do |env| posted_as = env[:request_headers]['Content-Type'] - [200, {'Content-Type' => posted_as}, env[:body]] + [200, { 'Content-Type' => posted_as }, env[:body]] end end end @@ -33,20 +33,20 @@ RSpec.describe Faraday::Request::UrlEncoded do end it 'works with with headers' do - response = conn.post('/echo', {'a'=>123}, 'content-type' => 'application/x-www-form-urlencoded') + response = conn.post('/echo', { 'a' => 123 }, 'content-type' => 'application/x-www-form-urlencoded') expect(response.headers['Content-Type']).to eq('application/x-www-form-urlencoded') expect(response.body).to eq('a=123') end it 'works with nested params' do - response = conn.post('/echo', { user: {name: 'Mislav', web: 'mislav.net'} }) + response = conn.post('/echo', { user: { name: 'Mislav', web: 'mislav.net' } }) expect(response.headers['Content-Type']).to eq('application/x-www-form-urlencoded') - expected = { 'user' => {'name' => 'Mislav', 'web' => 'mislav.net'} } + expected = { 'user' => { 'name' => 'Mislav', 'web' => 'mislav.net' } } expect(Faraday::Utils.parse_nested_query(response.body)).to eq(expected) end it 'works with non nested params' do - response = conn.post('/echo', { dimensions: ['date', 'location']}) do |req| + response = conn.post('/echo', { dimensions: ['date', 'location'] }) do |req| req.options.params_encoder = Faraday::FlatParamsEncoder end expect(response.headers['Content-Type']).to eq('application/x-www-form-urlencoded') @@ -57,14 +57,14 @@ 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 end it 'works with nested keys' do - response = conn.post('/echo', {'a'=>{'b'=>{'c'=>['d']}}}) + response = conn.post('/echo', { 'a' => { 'b' => { 'c' => ['d'] } } }) expect(response.body).to eq('a%5Bb%5D%5Bc%5D%5B%5D=d') end end diff --git a/spec/faraday/utils_spec.rb b/spec/faraday/utils_spec.rb index 43b37e6e..b7d0f3f5 100644 --- a/spec/faraday/utils_spec.rb +++ b/spec/faraday/utils_spec.rb @@ -40,7 +40,7 @@ RSpec.describe Faraday::Utils do end it 'parses with block' do - with_default_uri_parser(lambda {|u| "booya#{"!" * u.size}" }) do + with_default_uri_parser(lambda { |u| "booya#{"!" * u.size}" }) do expect(normalize(url)).to eq('booya!!!!!!!!!!!!!!!!!!!!!!') end end @@ -49,7 +49,7 @@ RSpec.describe Faraday::Utils do headers = Faraday::Utils::Headers.new('authorization' => 't0ps3cr3t!') expect(headers).to have_key('authorization') - headers.replace({'content-type' => 'text/plain'}) + headers.replace({ 'content-type' => 'text/plain' }) expect(headers).not_to have_key('authorization') end end diff --git a/spec/support/helper_methods.rb b/spec/support/helper_methods.rb index fa765c71..04755b4b 100644 --- a/spec/support/helper_methods.rb +++ b/spec/support/helper_methods.rb @@ -93,7 +93,7 @@ module Faraday def big_string kb = 1024 - (32..126).map{|i| i.chr}.cycle.take(50*kb).join + (32..126).map { |i| i.chr }.cycle.take(50 * kb).join end end end diff --git a/test/adapters/rack_test.rb b/test/adapters/rack_test.rb index 95747c3f..44cd11d3 100644 --- a/test/adapters/rack_test.rb +++ b/test/adapters/rack_test.rb @@ -25,7 +25,7 @@ module Adapters # not using shared test because error is swallowed by Sinatra def test_timeout - conn = create_connection(request: {timeout: 1, open_timeout: 1}) + conn = create_connection(request: { timeout: 1, open_timeout: 1 }) begin conn.get '/slow' rescue Faraday::ClientError diff --git a/test/adapters/test_middleware_test.rb b/test/adapters/test_middleware_test.rb index 8b9264d1..dbc07500 100644 --- a/test/adapters/test_middleware_test.rb +++ b/test/adapters/test_middleware_test.rb @@ -8,28 +8,28 @@ module Adapters def setup @stubs = Stubs.new do |stub| stub.get('/hello') do - [200, {'Content-Type' => 'text/html'}, 'hello'] + [200, { 'Content-Type' => 'text/html' }, 'hello'] end stub.get('/method-echo') do |env| - [200, {'Content-Type' => 'text/html'}, env[:method].to_s] + [200, { 'Content-Type' => 'text/html' }, env[:method].to_s] end stub.get(/\A\/resources\/\d+(?:\?|\z)/) do - [200, {'Content-Type' => 'text/html'}, 'show'] + [200, { 'Content-Type' => 'text/html' }, 'show'] end stub.get(/\A\/resources\/(specified)\z/) do |env, meta| - [200, {'Content-Type' => 'text/html'}, "show #{meta[:match_data][1]}"] + [200, { 'Content-Type' => 'text/html' }, "show #{meta[:match_data][1]}"] end stub.get('http://domain.test/hello') do - [200, {'Content-Type' => 'text/html'}, 'domain: hello'] + [200, { 'Content-Type' => 'text/html' }, 'domain: hello'] end stub.get('http://wrong.test/hello') do - [200, {'Content-Type' => 'text/html'}, 'wrong: hello'] + [200, { 'Content-Type' => 'text/html' }, 'wrong: hello'] end stub.get('http://wrong.test/bait') do - [404, {'Content-Type' => 'text/html'}] + [404, { 'Content-Type' => 'text/html' }] end end - @conn = Faraday.new do |builder| + @conn = Faraday.new do |builder| builder.adapter :test, @stubs end @resp = @conn.get('/hello') @@ -89,8 +89,8 @@ module Adapters end 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'] } + @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 end @@ -139,7 +139,7 @@ module Adapters def test_raises_an_error_if_no_stub_is_found_for_request assert_raises Stubs::NotFound do - @conn.get('/invalid'){ [200, {}, []] } + @conn.get('/invalid') { [200, {}, []] } end end diff --git a/test/shared.rb b/test/shared.rb index 8d2a6601..5d0c26fc 100644 --- a/test/shared.rb +++ b/test/shared.rb @@ -4,7 +4,7 @@ module Faraday module Shared def self.big_string kb = 1024 - (32..126).map{|i| i.chr}.cycle.take(50*kb).join + (32..126).map { |i| i.chr }.cycle.take(50 * kb).join end def big_string