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

Commit ef75a25

Browse files
committed
Revert "Make usage of keyword arguments for String#encode explicit to avoid warning on 2.7.0"
This reverts commit b2f4a68.
1 parent bbd38cd commit ef75a25

File tree

1 file changed

+2
-31
lines changed

1 file changed

+2
-31
lines changed

lib/rspec/support/encoded_string.rb

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -112,40 +112,11 @@ def matching_encoding(string)
112112
string = remove_invalid_bytes(string)
113113
string.encode(@encoding)
114114
rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError
115-
encode_unconvertable_bytes(string)
115+
string.encode(@encoding, ENCODE_UNCONVERTABLE_BYTES)
116116
rescue Encoding::ConverterNotFoundError
117-
encode_no_converter(string.dup.force_encoding(@encoding))
117+
string.dup.force_encoding(@encoding).encode(ENCODE_NO_CONVERTER)
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-
149120
# Prevents raising ArgumentError
150121
if String.method_defined?(:scrub)
151122
# https://github.com/ruby/ruby/blob/eeb05e8c11/doc/NEWS-2.1.0#L120-L123

0 commit comments

Comments
 (0)