Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 9d0482b

Browse files
authored
Merge pull request #392 from rspec/update-travis-build-scripts-2019-12-26-for-master
Ruby 2.7 support
2 parents a87275e + 0930546 commit 9d0482b

13 files changed

+61
-14
lines changed

.rubocop_rspec_base.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo.
1+
# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo.
22
# DO NOT modify it by hand as your changes will get lost the next time it is generated.
33

44
# This file contains defaults for RSpec projects. Individual projects

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo.
1+
# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo.
22
# DO NOT modify it by hand as your changes will get lost the next time it is generated.
33

44
# In order to install old Rubies, we need to use old Ubuntu distibution.
@@ -22,9 +22,10 @@ rvm:
2222
- 2.1
2323
- 2.2.10
2424
- 2.3.8
25-
- 2.4.6
26-
- 2.5.5
27-
- 2.6.2
25+
- 2.4.9
26+
- 2.5.7
27+
- 2.6.5
28+
- 2.7.0
2829
- ruby-head
2930
- ree
3031
- rbx-3

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo.
1+
# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo.
22
# DO NOT modify it by hand as your changes will get lost the next time it is generated.
33

44
version: "{build}"

lib/rspec/support/encoded_string.rb

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,40 @@ def matching_encoding(string)
112112
string = remove_invalid_bytes(string)
113113
string.encode(@encoding)
114114
rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError
115-
string.encode(@encoding, ENCODE_UNCONVERTABLE_BYTES)
115+
encode_unconvertable_bytes(string)
116116
rescue Encoding::ConverterNotFoundError
117-
string.dup.force_encoding(@encoding).encode(ENCODE_NO_CONVERTER)
117+
encode_no_converter(string.dup.force_encoding(@encoding))
118118
end
119119

120+
private
121+
122+
# On Ruby 2.7.0 keyword arguments mixed with conventional cause a warning to
123+
# be issued requiring us to be explicit by using a ** to pass the hash as
124+
# keyword arguments. Any keyword argument supporting Ruby supports this.
125+
if RubyFeatures.kw_args_supported?
126+
# Note on non keyword supporting Ruby ** causes a syntax error hence
127+
# we must use eval. To be removed in RSpec 4.
128+
binding.eval(<<-CODE, __FILE__, __LINE__)
129+
def encode_unconvertable_bytes(string)
130+
string.encode(@encoding, **ENCODE_UNCONVERTABLE_BYTES)
131+
end
132+
133+
def encode_no_converter(string)
134+
string.encode(**ENCODE_NO_CONVERTER)
135+
end
136+
CODE
137+
else
138+
def encode_unconvertable_bytes(string)
139+
string.encode(@encoding, ENCODE_UNCONVERTABLE_BYTES)
140+
end
141+
142+
def encode_no_converter(string)
143+
string.encode(ENCODE_NO_CONVERTER)
144+
end
145+
end
146+
147+
public
148+
120149
# Prevents raising ArgumentError
121150
if String.method_defined?(:scrub)
122151
# https://github.com/ruby/ruby/blob/eeb05e8c11/doc/NEWS-2.1.0#L120-L123

lib/rspec/support/ruby_features.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ def supports_exception_cause?
9090
end
9191
end
9292

93+
if RUBY_VERSION.to_f >= 2.7
94+
def supports_taint?
95+
false
96+
end
97+
else
98+
def supports_taint?
99+
true
100+
end
101+
end
93102
ripper_requirements = [ComparableVersion.new(RUBY_VERSION) >= '1.9.2']
94103

95104
ripper_requirements.push(false) if Ruby.rbx?

lib/rspec/support/spec/stderr_splitter.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ def to_io
3838
def write(line)
3939
return if line =~ %r{^\S+/gems/\S+:\d+: warning:} # http://rubular.com/r/kqeUIZOfPG
4040

41+
# Ruby 2.7.0 complains about hashes used in place of keyword arguments
42+
# Aruba 0.14.2 uses this internally triggering that here
43+
return if line =~ %r{lib/ruby/2\.7\.0/fileutils\.rb:622: warning:}
44+
4145
@orig_stderr.write(line)
4246
@output_tracker.write(line)
4347
end

script/clone_all_rspec_repos

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo.
2+
# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo.
33
# DO NOT modify it by hand as your changes will get lost the next time it is generated.
44

55
set -e

script/functions.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo.
1+
# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo.
22
# DO NOT modify it by hand as your changes will get lost the next time it is generated.
33

44
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

script/predicate_functions.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo.
1+
# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo.
22
# DO NOT modify it by hand as your changes will get lost the next time it is generated.
33

44
function is_mri {

script/run_build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo.
2+
# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo.
33
# DO NOT modify it by hand as your changes will get lost the next time it is generated.
44

55
set -e

script/travis_functions.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo.
1+
# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo.
22
# DO NOT modify it by hand as your changes will get lost the next time it is generated.
33

44
# Taken from:

script/update_rubygems_and_install_bundler

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# This file was generated on 2019-12-18T14:01:39+00:00 from the rspec-dev repo.
2+
# This file was generated on 2019-12-26T17:20:33+00:00 from the rspec-dev repo.
33
# DO NOT modify it by hand as your changes will get lost the next time it is generated.
44

55
set -e

spec/rspec/support/ruby_features_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ module Support
9595
RubyFeatures.supports_rebinding_module_methods?
9696
end
9797

98+
specify "#supports_taint?" do
99+
RubyFeatures.supports_taint?
100+
end
101+
98102
specify "#caller_locations_supported? exists" do
99103
RubyFeatures.caller_locations_supported?
100104
if Ruby.mri?

0 commit comments

Comments
 (0)