From a712938071bb0997410b5de4a4f2517d30fc4d3d Mon Sep 17 00:00:00 2001 From: Leon Miller-Out Date: Fri, 26 Aug 2016 16:45:28 -0400 Subject: [PATCH] Fix Ruby 1.9.3 tests on Travis. Drop support for Ruby 1.8.7. (#600) * Drop support for Ruby 1.9.2, which no-one should be using any more. * Constraint gem versions for Ruby 1.9.3 * Drop support for Ruby 1.8.7. Many dependencies have dropped support for it. * Remove conditionals checking for Ruby 1.8.7 * Document Ruby version dependency --- .travis.yml | 4 ---- Gemfile | 13 +++++++++++-- README.md | 2 +- faraday.gemspec | 2 ++ lib/faraday.rb | 9 --------- script/test | 6 +----- test/adapters/em_synchrony_test.rb | 20 +++++++++++--------- test/adapters/net_http_test.rb | 3 +-- test/adapters/patron_test.rb | 19 ++++++++++--------- test/composite_read_io_test.rb | 24 +++++++++++------------- test/helper.rb | 16 +++++++--------- test/options_test.rb | 6 +----- test/request_middleware_test.rb | 24 ------------------------ 13 files changed, 56 insertions(+), 92 deletions(-) diff --git a/.travis.yml b/.travis.yml index 74e0d908..2538a7c2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,14 +4,11 @@ script: bundle exec script/test cache: bundler rvm: - - 1.8.7 - - 1.9.2 - 1.9.3 - 2.0.0 - 2.1 - 2.2 - 2.3.1 - - jruby-18mode - jruby-19mode - jruby-20mode - jruby-21mode @@ -22,7 +19,6 @@ matrix: allow_failures: # "A fatal error has been detected by the Java Runtime Environment: # Internal Error (sharedRuntime.cpp:843)" - - rvm: jruby-18mode - rvm: jruby-19mode - rvm: jruby-20mode - rvm: jruby-21mode diff --git a/Gemfile b/Gemfile index cc9269d8..648da9b3 100644 --- a/Gemfile +++ b/Gemfile @@ -2,8 +2,7 @@ source 'https://rubygems.org' gem 'ffi-ncurses', '~> 0.3', :platforms => :jruby gem 'jruby-openssl', '~> 0.8.8', :platforms => :jruby -# Newer versions drop support for Ruby < 1.9.3, but we still support them. -gem 'rake', '< 11.0.0' +gem 'rake' group :test do gem 'coveralls', :require => false @@ -21,6 +20,16 @@ group :test do gem 'simplecov' gem 'sinatra', '~> 1.3' gem 'typhoeus', '~> 0.3.3', :platforms => [:ruby_18, :ruby_19, :ruby_20, :ruby_21] + + # Below are dependencies of the gems we actually care about that have + # dropped support for older Rubies. Because they are not first-level + # dependencies, we don't need to specify an unconstrained version, so we can + # lump them together here. + + if RUBY_VERSION < '2' + gem 'json', '< 2' + gem 'tins', '< 1.7.0' + end end gemspec diff --git a/README.md b/README.md index 4ae63432..a5a10db0 100644 --- a/README.md +++ b/README.md @@ -210,7 +210,7 @@ stubs.verify_stubbed_calls This library aims to support and is [tested against][travis] the following Ruby implementations: -* Ruby 1.8.7+ +* Ruby 1.9.3+ * [JRuby][] 1.7+ * [Rubinius][] 2+ diff --git a/faraday.gemspec b/faraday.gemspec index 1f7356dc..5693475f 100644 --- a/faraday.gemspec +++ b/faraday.gemspec @@ -14,6 +14,8 @@ Gem::Specification.new do |spec| spec.homepage = 'https://github.com/lostisland/faraday' spec.licenses = ['MIT'] + spec.required_ruby_version = '>= 1.9' + spec.add_dependency 'multipart-post', '>= 1.2', '< 3' spec.files = `git ls-files -z lib LICENSE.md README.md`.split("\0") diff --git a/lib/faraday.rb b/lib/faraday.rb index bd588224..d207c3da 100644 --- a/lib/faraday.rb +++ b/lib/faraday.rb @@ -122,15 +122,6 @@ module Faraday @default_connection_options ||= ConnectionOptions.new end - if (!defined?(RUBY_ENGINE) || "ruby" == RUBY_ENGINE) && RUBY_VERSION < '1.9' - begin - require 'system_timer' - Timer = SystemTimer - rescue LoadError - warn "Faraday: you may want to install system_timer for reliable timeouts" - end - end - unless const_defined? :Timer require 'timeout' Timer = Timeout diff --git a/script/test b/script/test index 33795816..961d0fc3 100755 --- a/script/test +++ b/script/test @@ -20,11 +20,7 @@ set -e if [[ "$RUBYOPT" != *"bundler/setup"* ]]; then - if [[ "$(ruby -v)" == "ruby 1.8."* ]]; then - exec bundle exec "$0" - else - export RUBYOPT="-rbundler/setup $RUBYOPT" - fi + export RUBYOPT="-rbundler/setup $RUBYOPT" fi port=3999 diff --git a/test/adapters/em_synchrony_test.rb b/test/adapters/em_synchrony_test.rb index 59cdef7c..3cd63997 100644 --- a/test/adapters/em_synchrony_test.rb +++ b/test/adapters/em_synchrony_test.rb @@ -5,16 +5,18 @@ module Adapters def adapter() :em_synchrony end - Integration.apply(self, :Parallel) do - # https://github.com/eventmachine/eventmachine/pull/289 - undef :test_timeout + unless jruby? + Integration.apply(self, :Parallel) do + # https://github.com/eventmachine/eventmachine/pull/289 + undef :test_timeout - def test_binds_local_socket - host = '1.2.3.4' - conn = create_connection :request => { :bind => { :host => host } } - #put conn.get('/who-am-i').body - assert_equal host, conn.options[:bind][:host] + def test_binds_local_socket + host = '1.2.3.4' + conn = create_connection :request => { :bind => { :host => host } } + #put conn.get('/who-am-i').body + assert_equal host, conn.options[:bind][:host] + end end - end unless RUBY_VERSION < '1.9' or jruby? + end end end diff --git a/test/adapters/net_http_test.rb b/test/adapters/net_http_test.rb index 1bd60dba..29630056 100644 --- a/test/adapters/net_http_test.rb +++ b/test/adapters/net_http_test.rb @@ -7,8 +7,7 @@ module Adapters def adapter() :net_http end - behaviors = [:NonParallel] - behaviors << :Compression if RUBY_VERSION >= '1.9' + behaviors = [:NonParallel, :Compression] Integration.apply(self, *behaviors) diff --git a/test/adapters/patron_test.rb b/test/adapters/patron_test.rb index a25028e1..dfec0517 100644 --- a/test/adapters/patron_test.rb +++ b/test/adapters/patron_test.rb @@ -5,16 +5,17 @@ module Adapters def adapter() :patron end - Integration.apply(self, :NonParallel) do - # https://github.com/toland/patron/issues/34 - undef :test_PATCH_send_url_encoded_params + unless jruby? + Integration.apply(self, :NonParallel) do + # https://github.com/toland/patron/issues/34 + undef :test_PATCH_send_url_encoded_params - # https://github.com/toland/patron/issues/52 - undef :test_GET_with_body - - # no support for SSL peer verification - undef :test_GET_ssl_fails_with_bad_cert if ssl_mode? - end unless RUBY_VERSION < '1.9' or jruby? + # https://github.com/toland/patron/issues/52 + undef :test_GET_with_body + # no support for SSL peer verification + undef :test_GET_ssl_fails_with_bad_cert if ssl_mode? + end + end end end diff --git a/test/composite_read_io_test.rb b/test/composite_read_io_test.rb index 0632dee4..bda3cd6e 100644 --- a/test/composite_read_io_test.rb +++ b/test/composite_read_io_test.rb @@ -86,21 +86,19 @@ class CompositeReadIOTest < Faraday::TestCase end end - unless RUBY_VERSION < '1.9' - def test_read_from_multibyte - File.open(File.dirname(__FILE__) + '/multibyte.txt') do |utf8| - io = composite_io(part("\x86"), Part.new(utf8)) - assert_equal bin("\x86\xE3\x83\x95\xE3\x82\xA1\xE3\x82\xA4\xE3\x83\xAB\n"), io.read - end + def test_read_from_multibyte + File.open(File.dirname(__FILE__) + '/multibyte.txt') do |utf8| + io = composite_io(part("\x86"), Part.new(utf8)) + assert_equal bin("\x86\xE3\x83\x95\xE3\x82\xA1\xE3\x82\xA4\xE3\x83\xAB\n"), io.read end + end - def test_limited_from_multibyte - File.open(File.dirname(__FILE__) + '/multibyte.txt') do |utf8| - io = composite_io(part("\x86"), Part.new(utf8)) - assert_equal bin("\x86\xE3\x83"), io.read(3) - assert_equal bin("\x95\xE3\x82"), io.read(3) - assert_equal bin("\xA1\xE3\x82\xA4\xE3\x83\xAB\n"), io.read(8) - end + def test_limited_from_multibyte + File.open(File.dirname(__FILE__) + '/multibyte.txt') do |utf8| + io = composite_io(part("\x86"), Part.new(utf8)) + assert_equal bin("\x86\xE3\x83"), io.read(3) + assert_equal bin("\x95\xE3\x82"), io.read(3) + assert_equal bin("\xA1\xE3\x82\xA4\xE3\x83\xAB\n"), io.read(8) end end diff --git a/test/helper.rb b/test/helper.rb index a76df69a..37172313 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -1,14 +1,12 @@ -if RUBY_VERSION >= '1.9' - require 'simplecov' - require 'coveralls' +require 'simplecov' +require 'coveralls' - SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter] +SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter] - SimpleCov.start do - add_filter '/bundle/' - add_filter '/test/' - minimum_coverage(87) - end +SimpleCov.start do + add_filter '/bundle/' + add_filter '/test/' + minimum_coverage(87) end gem 'minitest' if defined? Bundler diff --git a/test/options_test.rb b/test/options_test.rb index 1cacdf66..c23da006 100644 --- a/test/options_test.rb +++ b/test/options_test.rb @@ -34,11 +34,7 @@ class OptionsTest < Faraday::TestCase options = SubOptions.new assert !options.key?(:sub) options.sub = 1 - if RUBY_VERSION >= '1.9' - assert options.key?(:sub) - else - assert options.key?("sub") - end + assert options.key?(:sub) end def test_each_value diff --git a/test/request_middleware_test.rb b/test/request_middleware_test.rb index aca011f9..0e837ca6 100644 --- a/test/request_middleware_test.rb +++ b/test/request_middleware_test.rb @@ -17,20 +17,6 @@ class RequestMiddlewareTest < Faraday::TestCase end end - def with_utf8 - if defined?(RUBY_VERSION) && RUBY_VERSION.match(/1.8.\d/) - begin - previous_kcode = $KCODE - $KCODE = "UTF8" - yield - ensure - $KCODE = previous_kcode - end - else - yield - end - end - def test_does_nothing_without_payload response = @conn.post('/echo') assert_nil response.headers['Content-Type'] @@ -80,16 +66,6 @@ class RequestMiddlewareTest < Faraday::TestCase assert err.empty?, "stderr did include: #{err}" end - def test_url_encoded_unicode_with_kcode_set - with_utf8 do - err = capture_warnings { - response = @conn.post('/echo', {:str => "eé cç aã aâ"}) - assert_equal "str=e%C3%A9+c%C3%A7+a%C3%A3+a%C3%A2", response.body - } - assert err.empty?, "stderr did include: #{err}" - end - end - def test_url_encoded_nested_keys response = @conn.post('/echo', {'a'=>{'b'=>{'c'=>['d']}}}) assert_equal "a%5Bb%5D%5Bc%5D%5B%5D=d", response.body