From b38369dcace01aa4026abd42209a3025ed719d62 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Sun, 12 Apr 2020 23:41:12 +0200 Subject: [PATCH] =?UTF-8?q?Breaking:=20Require=20ruby=202.3=20or=20newer,?= =?UTF-8?q?=20to=20be=20able=20to=20use=20latest=20Cu=E2=80=A6=20(#816)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * BREAKING: ruby_version_required: 2.3+ * Update cucumber to ~> 3.1 * Ruby 2.7 keyword compat * gemspec: Allow Excon >= 0.62.0 * Avoid Cucumber ~@tag warnings - by using new syntax for tag exclusion, we avoid all start warnings * CI: Add 2.7 to the matrix * Ruby 3.0 keyword compat * Use Cucumber 3.1 - the supported version * Drop RUBY_VERSION checks for old versions --- .travis.yml | 1 + Gemfile.cucumber-1.3 => Gemfile.cucumber-3.1 | 2 +- cucumber.yml | 16 ++++++++-------- features/support/env.rb | 8 +++----- lib/vcr/structs.rb | 7 ++++--- script/ci.sh | 2 +- spec/lib/vcr/cassette/migrator_spec.rb | 10 ---------- spec/lib/vcr/cassette/serializers_spec.rb | 18 +----------------- spec/lib/vcr/configuration_spec.rb | 2 +- spec/lib/vcr/structs_spec.rb | 2 +- spec/support/http_library_adapters.rb | 2 +- .../hook_into_http_library.rb | 2 +- spec/support/vcr_localhost_server.rb | 2 +- vcr.gemspec | 6 +++--- 14 files changed, 27 insertions(+), 53 deletions(-) rename Gemfile.cucumber-1.3 => Gemfile.cucumber-3.1 (58%) diff --git a/.travis.yml b/.travis.yml index 7d240ae6..9621b16c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,3 +7,4 @@ rvm: - 2.4 - 2.5 - 2.6 + - 2.7 diff --git a/Gemfile.cucumber-1.3 b/Gemfile.cucumber-3.1 similarity index 58% rename from Gemfile.cucumber-1.3 rename to Gemfile.cucumber-3.1 index d3ae45b0..bc4bfda0 100644 --- a/Gemfile.cucumber-1.3 +++ b/Gemfile.cucumber-3.1 @@ -1,5 +1,5 @@ source "https://rubygems.org" -gem "cucumber", "~> 1.3.20" +gem "cucumber", "~> 3.1" gemspec diff --git a/cucumber.yml b/cucumber.yml index 4964045d..34a73490 100644 --- a/cucumber.yml +++ b/cucumber.yml @@ -1,17 +1,17 @@ <% base_opts = '--require features/step_definitions --require features/support' -std_opts = "--format progress --strict" -std_opts << " --backtrace" if ENV["CI"] +std_opts = +"--format progress --strict" +std_opts << " --backtrace" if ENV["CI"] rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : "" rerun_opts = rerun.to_s.strip.empty? ? "--format progress features" : "--format pretty #{rerun}" exclusions = [] -exclusions << "--tags ~@exclude-#{RUBY_VERSION.split('.').first(2).join}" -exclusions << "--tags ~@exclude-#{RUBY_VERSION}p#{RUBY_PATCHLEVEL}" -exclusions << "--tags ~@exclude-#{RUBY_ENGINE}" if defined?(RUBY_ENGINE) +exclusions << "--tags 'not @exclude-#{RUBY_VERSION.split('.').first(2).join}'" +exclusions << "--tags 'not @exclude-#{RUBY_VERSION}p#{RUBY_PATCHLEVEL}'" +exclusions << "--tags 'not @exclude-#{RUBY_ENGINE}'" if defined?(RUBY_ENGINE) exclusions = exclusions.join(' ') %> -default: <%= base_opts %> <%= std_opts %> --tags ~@wip <%= exclusions %> features -wip: <%= base_opts %> --tags @wip <%= exclusions %> features -rerun: <%= base_opts %> <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip <%= exclusions %> +default: <%= base_opts %> <%= std_opts %> --tags 'not @wip' <%= exclusions %> features +wip: <%= base_opts %> --tags 'not wip' <%= exclusions %> features +rerun: <%= base_opts %> <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags 'not @wip' <%= exclusions %> diff --git a/features/support/env.rb b/features/support/env.rb index e257ba75..4e00c612 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -18,10 +18,8 @@ load_paths << File.expand_path("../../../spec", __FILE__) rubyopt = "-rsupport/cucumber_helpers" -if RUBY_VERSION > '1.9' - load_paths.unshift(".") - rubyopt = "--disable-gems #{rubyopt}" unless "rbx" == ruby_engine -end +load_paths.unshift(".") +rubyopt = "--disable-gems #{rubyopt}" unless "rbx" == ruby_engine Before do if "jruby" == ruby_engine @@ -31,7 +29,7 @@ end end -Before("~@with-bundler") do +Before("not @with-bundler") do set_environment_variable("RUBYLIB", load_paths.join(":")) set_environment_variable("RUBYOPT", rubyopt) set_environment_variable("RBXOPT", "--disable-gems #{ENV["RBXOPT"]}") if "rbx" == ruby_engine diff --git a/lib/vcr/structs.rb b/lib/vcr/structs.rb index a825e75b..8510188c 100644 --- a/lib/vcr/structs.rb +++ b/lib/vcr/structs.rb @@ -454,9 +454,10 @@ def self.decompress(body, type) case type when 'gzip' - args = [StringIO.new(body)] - args << { :encoding => 'ASCII-8BIT' } if ''.respond_to?(:encoding) - yield Zlib::GzipReader.new(*args).read + gzip_reader_options = {} + gzip_reader_options[:encoding] = 'ASCII-8BIT' if ''.respond_to?(:encoding) + yield Zlib::GzipReader.new(StringIO.new(body), + **gzip_reader_options).read when 'deflate' yield Zlib::Inflate.inflate(body) when 'identity', NilClass diff --git a/script/ci.sh b/script/ci.sh index b78157a6..9d152ea7 100755 --- a/script/ci.sh +++ b/script/ci.sh @@ -90,7 +90,7 @@ BUNDLE_GEMFILE=Gemfile.faraday-1.0.0 fold "faraday-1.0.0" \ run script/test spec/lib/vcr/middleware/faraday_spec.rb spec/lib/vcr/library_hooks/faraday_spec.rb \ features/middleware/faraday.feature -BUNDLE_GEMFILE=Gemfile.cucumber-1.3 fold "cucumber-1.3" \ +BUNDLE_GEMFILE=Gemfile.cucumber-3.1 fold "cucumber-3.1" \ run script/test features/test_frameworks/cucumber.feature fold "spec" run script/test spec/ diff --git a/spec/lib/vcr/cassette/migrator_spec.rb b/spec/lib/vcr/cassette/migrator_spec.rb index d3b4d5d3..dba82d25 100644 --- a/spec/lib/vcr/cassette/migrator_spec.rb +++ b/spec/lib/vcr/cassette/migrator_spec.rb @@ -114,16 +114,6 @@ updated_contents.gsub!(/^(- | )/, ' \1') end if RUBY_PLATFORM == 'java' - # Use syck on all rubies for consistent results... - around(:each) do |example| - YAML::ENGINE.yamler = 'syck' - begin - example.call - ensure - YAML::ENGINE.yamler = 'psych' - end - end if defined?(YAML::ENGINE) && RUBY_VERSION.to_f < 2.0 - let(:filemtime) { Time.utc(2011, 5, 4, 12, 30) } let(:out_io) { StringIO.new } let(:file_name) { File.join(dir, "example.yml") } diff --git a/spec/lib/vcr/cassette/serializers_spec.rb b/spec/lib/vcr/cassette/serializers_spec.rb index c4c2fba6..6bf003cf 100644 --- a/spec/lib/vcr/cassette/serializers_spec.rb +++ b/spec/lib/vcr/cassette/serializers_spec.rb @@ -17,7 +17,7 @@ class Cassette result = serializer.serialize("a" => string) serializer.deserialize(result) }.to raise_error(error_class, /preserve_exact_body_bytes/) - end unless (RUBY_INTERPRETER == :rubinius && RUBY_VERSION =~ /^1.9/) + end end end @@ -81,14 +81,6 @@ class Cassette engines[:yajl] = MultiJson::LoadError end - if RUBY_VERSION =~ /1.9/ - engines[:json_gem] = EncodingError - - # Disable json_pure for now due to this bug: - # https://github.com/flori/json/issues/186 - # engines[:json_pure] = EncodingError - end - engines.each do |engine, error| context "when MultiJson is configured to use #{engine.inspect}", :unless => (RUBY_INTERPRETER == :jruby) do before { MultiJson.engine = engine } @@ -168,14 +160,6 @@ def obj.deserialize(string) expect { subject[:psych] }.to raise_error(LoadError) end unless defined?(::Psych) end - - describe "syck serializer" do - it 'forcibly serializes things using syck even if psych is the currently configured YAML engine' do - ::YAML::ENGINE.yamler = 'psych' - serialized = subject[:syck].serialize(problematic_syck_string) - expect(subject[:syck].deserialize(serialized)).not_to eq(problematic_syck_string) - end if defined?(::Psych) && (RUBY_INTERPRETER != :jruby) && (RUBY_VERSION.to_f < 2.0) - end end end end diff --git a/spec/lib/vcr/configuration_spec.rb b/spec/lib/vcr/configuration_spec.rb index a2e98bff..1281d943 100644 --- a/spec/lib/vcr/configuration_spec.rb +++ b/spec/lib/vcr/configuration_spec.rb @@ -144,7 +144,7 @@ expect(before_record_req).not_to respond_to(:type) expect(before_request_req).to respond_to(:type) - end unless (RUBY_VERSION =~ /^1\.8/ || RUBY_INTERPRETER == :jruby) + end unless (RUBY_INTERPRETER == :jruby) specify 'the filter_sensitive_data option works even when it modifies the URL in a way that makes it an invalid URI' do VCR.configure do |c| diff --git a/spec/lib/vcr/structs_spec.rb b/spec/lib/vcr/structs_spec.rb index da8c03ae..40c119dc 100644 --- a/spec/lib/vcr/structs_spec.rb +++ b/spec/lib/vcr/structs_spec.rb @@ -583,7 +583,7 @@ def uri_for(uri) expect(Fiber).to receive(:yield) lambda(&subject).call end - end if RUBY_VERSION > '1.9' + end it_behaves_like 'a header normalizer' do def with_headers(headers) diff --git a/spec/support/http_library_adapters.rb b/spec/support/http_library_adapters.rb index 90d7668b..2730b967 100644 --- a/spec/support/http_library_adapters.rb +++ b/spec/support/http_library_adapters.rb @@ -36,7 +36,7 @@ def make_http_request(method, url, body = nil, headers = {}) DEFAULT_REQUEST_HEADERS = { "Accept"=>["*/*"] } DEFAULT_REQUEST_HEADERS['User-Agent'] = ["Ruby"] - DEFAULT_REQUEST_HEADERS['Accept-Encoding'] = ["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"] if RUBY_VERSION.to_f > 1.9 + DEFAULT_REQUEST_HEADERS['Accept-Encoding'] = ["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"] def normalize_request_headers(headers) defined?(super) ? super : diff --git a/spec/support/shared_example_groups/hook_into_http_library.rb b/spec/support/shared_example_groups/hook_into_http_library.rb index 31710733..cc57bb4e 100644 --- a/spec/support/shared_example_groups/hook_into_http_library.rb +++ b/spec/support/shared_example_groups/hook_into_http_library.rb @@ -314,7 +314,7 @@ def self.test_playback(description, url) make_http_request(:get, request_url) expect(order).to eq([:before_1, :after_1]) end - end if RUBY_VERSION >= '1.9' + end it 'correctly assigns the correct type to both before and after request hooks, even if they are different' do before_type = after_type = nil diff --git a/spec/support/vcr_localhost_server.rb b/spec/support/vcr_localhost_server.rb index 9be78222..9830643c 100644 --- a/spec/support/vcr_localhost_server.rb +++ b/spec/support/vcr_localhost_server.rb @@ -44,7 +44,7 @@ def boot # Use WEBrick since it's part of the ruby standard library and is available on all ruby interpreters. options = { :Port => port, :ShutdownSocketWithoutClose => true } options.merge!(:AccessLog => [], :Logger => WEBrick::BasicLog.new(StringIO.new)) unless ENV['VERBOSE_SERVER'] - Rack::Handler::WEBrick.run(Identify.new(@rack_app), options) + Rack::Handler::WEBrick.run(Identify.new(@rack_app), **options) end def booted? diff --git a/vcr.gemspec b/vcr.gemspec index 348d0ec6..d5c83fd2 100644 --- a/vcr.gemspec +++ b/vcr.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |spec| spec.executables = Dir[File.join("bin", "**", "*")].map! { |f| f.gsub(/bin\//, "") } spec.require_paths = ["lib"] - spec.required_ruby_version = ">= 1.9.3" + spec.required_ruby_version = ">= 2.3" spec.add_development_dependency "bundler", "~> 2.0" spec.add_development_dependency "rspec", "~> 3.0" @@ -32,11 +32,11 @@ Gem::Specification.new do |spec| spec.add_development_dependency "rack" spec.add_development_dependency "webmock" spec.add_development_dependency "hashdiff", ">= 1.0.0.beta1", "< 2.0.0" - spec.add_development_dependency "cucumber", "~> 2.0.2" + spec.add_development_dependency "cucumber", "~> 3.1" spec.add_development_dependency "aruba", "~> 0.14.14" spec.add_development_dependency "faraday", ">= 0.11.0", "< 2.0.0" spec.add_development_dependency "httpclient" - spec.add_development_dependency "excon", "0.62.0" + spec.add_development_dependency "excon", ">= 0.62.0" spec.add_development_dependency "timecop" spec.add_development_dependency "multi_json" spec.add_development_dependency "json"