Skip to content

Commit

Permalink
Breaking: Require ruby 2.3 or newer, to be able to use latest Cu… (vc…
Browse files Browse the repository at this point in the history
…r#816)

* 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
  • Loading branch information
olleolleolle authored Apr 12, 2020
1 parent 064010e commit b38369d
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 53 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ rvm:
- 2.4
- 2.5
- 2.6
- 2.7
2 changes: 1 addition & 1 deletion Gemfile.cucumber-1.3 → Gemfile.cucumber-3.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source "https://rubygems.org"

gem "cucumber", "~> 1.3.20"
gem "cucumber", "~> 3.1"

gemspec
16 changes: 8 additions & 8 deletions cucumber.yml
Original file line number Diff line number Diff line change
@@ -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 %>

8 changes: 3 additions & 5 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions lib/vcr/structs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion script/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
10 changes: 0 additions & 10 deletions spec/lib/vcr/cassette/migrator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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") }
Expand Down
18 changes: 1 addition & 17 deletions spec/lib/vcr/cassette/serializers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vcr/structs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion spec/support/http_library_adapters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/support/vcr_localhost_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
6 changes: 3 additions & 3 deletions vcr.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down

0 comments on commit b38369d

Please sign in to comment.