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

Commit a4833b4

Browse files
committed
Remove assorted older rubies workarounds
1 parent 61d2acd commit a4833b4

File tree

10 files changed

+46
-89
lines changed

10 files changed

+46
-89
lines changed

lib/rspec/support/spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def self.setup_simplecov(&block)
4848
# Simplecov emits some ruby warnings when loaded, so silence them.
4949
old_verbose, $VERBOSE = $VERBOSE, false
5050

51-
return if ENV['NO_COVERAGE'] || RUBY_VERSION < '1.9.3'
51+
return if ENV['NO_COVERAGE']
5252
return if RUBY_ENGINE != 'ruby' || RSpec::Support::OS.windows?
5353

5454
# Don't load it when we're running a single isolated

lib/rspec/support/spec/library_wide_checks.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def load_all_files(files, preamble, postamble=nil)
6464

6565
stdout, stderr, status = with_env 'NO_COVERAGE' => '1' do
6666
options = %w[ -w ]
67-
options << "--disable=gem" if RUBY_VERSION.to_f >= 1.9 && RSpec::Support::Ruby.mri?
67+
options << "--disable=gem" if RSpec::Support::Ruby.mri?
6868
run_ruby_with_current_load_path(command, *options)
6969
end
7070

@@ -115,14 +115,6 @@ def have_successful_no_warnings_output
115115
it 'only loads a known set of stdlibs so gem authors are forced ' \
116116
'to load libs they use to have passing specs', :slow do
117117
loaded_features = @loaded_feature_lines.split("\n")
118-
if RUBY_VERSION == '1.8.7'
119-
# On 1.8.7, $" returns the relative require path if that was used
120-
# to require the file. LIB_REGEX will not match the relative version
121-
# since it has a `/lib` prefix. Here we deal with this by expanding
122-
# relative files relative to the $LOAD_PATH dir (lib).
123-
Dir.chdir("lib") { loaded_features.map! { |f| File.expand_path(f) } }
124-
end
125-
126118
loaded_features.reject! { |feature| RSpec::CallerFilter::LIB_REGEX =~ feature }
127119
loaded_features.reject! { |feature| allowed_loaded_feature_regexps.any? { |r| r =~ feature } }
128120

spec/rspec/support/differ_spec.rb

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -287,34 +287,32 @@ def inspect; "<BrokenObject>"; end
287287
expect(diff).to be_diffed_as(expected_diff)
288288
end
289289

290-
unless RUBY_VERSION == '1.8.7' # We can't count on the ordering of the hash on 1.8.7...
291-
it "outputs unified diff message for hashes inside arrays with differing key orders" do
292-
expected = [{ :foo => 'bar', :baz => 'quux', :metasyntactic => 'variable', :delta => 'charlie', :width =>'quite wide' }]
293-
actual = [{ :metasyntactic => 'variable', :delta => 'charlotte', :width =>'quite wide', :foo => 'bar' }]
290+
it "outputs unified diff message for hashes inside arrays with differing key orders" do
291+
expected = [{ :foo => 'bar', :baz => 'quux', :metasyntactic => 'variable', :delta => 'charlie', :width =>'quite wide' }]
292+
actual = [{ :metasyntactic => 'variable', :delta => 'charlotte', :width =>'quite wide', :foo => 'bar' }]
294293

295-
expected_diff = dedent(<<-'EOD')
296-
|
297-
|@@ -1,4 +1,5 @@
298-
|-[{:delta=>"charlotte",
299-
|+[{:baz=>"quux",
300-
|+ :delta=>"charlie",
301-
| :foo=>"bar",
302-
| :metasyntactic=>"variable",
303-
| :width=>"quite wide"}]
304-
|
305-
EOD
294+
expected_diff = dedent(<<-'EOD')
295+
|
296+
|@@ -1,4 +1,5 @@
297+
|-[{:delta=>"charlotte",
298+
|+[{:baz=>"quux",
299+
|+ :delta=>"charlie",
300+
| :foo=>"bar",
301+
| :metasyntactic=>"variable",
302+
| :width=>"quite wide"}]
303+
|
304+
EOD
306305

307-
diff = differ.diff(expected,actual)
308-
expect(diff).to be_diffed_as(expected_diff)
309-
end
306+
diff = differ.diff(expected,actual)
307+
expect(diff).to be_diffed_as(expected_diff)
310308
end
311309

312310
it 'outputs unified diff message of two hashes with differing encoding', :failing_on_appveyor do
313311
expected_diff = dedent(<<-"EOD")
314312
|
315313
|@@ #{one_line_header} @@
316314
|-"a" => "a",
317-
|#{ (RUBY_VERSION.to_f > 1.8) ? %Q{+"ö" => "ö"} : '+"\303\266" => "\303\266"' },
315+
|+"ö" => "ö",
318316
|
319317
EOD
320318

@@ -327,7 +325,7 @@ def inspect; "<BrokenObject>"; end
327325
|
328326
|@@ #{one_line_header} @@
329327
|-:a => "a",
330-
|#{ (RUBY_VERSION.to_f > 1.8) ? %Q{+\"한글\" => \"한글2\"} : '+"\355\225\234\352\270\200" => "\355\225\234\352\270\2002"' },
328+
|+\"한글\" => \"한글2\",
331329
|
332330
EOD
333331

spec/rspec/support/encoded_string_spec.rb

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -72,26 +72,16 @@ module RSpec::Support
7272
}.to raise_error(Encoding::ConverterNotFoundError)
7373
end
7474

75-
# See comment above ENCODE_UNCONVERTABLE_BYTES in encoded_string.rb
76-
# for why the behavior differs by (MRI) Ruby version.
77-
if RUBY_VERSION < '2.1'
78-
it 'does nothing' do
79-
resulting_string = build_encoded_string(string, no_converter_encoding).to_s
80-
expected_string = forced_encoding("\x80", no_converter_encoding)
81-
expect(resulting_string).to be_identical_string(expected_string).with_same_encoding
82-
end
83-
else
84-
it 'forces the encoding and replaces invalid characters with the REPLACE string' do
85-
resulting_string = build_encoded_string(string, no_converter_encoding).to_s
86-
expected_string = forced_encoding(EncodedString::REPLACE, no_converter_encoding)
87-
expect(resulting_string).to be_identical_string(expected_string).with_same_encoding
88-
end
75+
it 'forces the encoding and replaces invalid characters with the REPLACE string' do
76+
resulting_string = build_encoded_string(string, no_converter_encoding).to_s
77+
expected_string = forced_encoding(EncodedString::REPLACE, no_converter_encoding)
78+
expect(resulting_string).to be_identical_string(expected_string).with_same_encoding
79+
end
8980

90-
it 'does not mutate the input string' do
91-
expect {
92-
build_encoded_string(string, no_converter_encoding)
93-
}.not_to change { [string, string.encoding] }
94-
end
81+
it 'does not mutate the input string' do
82+
expect {
83+
build_encoded_string(string, no_converter_encoding)
84+
}.not_to change { [string, string.encoding] }
9585
end
9686
end
9787

spec/rspec/support/object_formatter_spec.rb

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,17 @@ module Support
2222

2323
it 'formats those objects within the hash output, at any level of nesting' do
2424
formatted = ObjectFormatter.format(input)
25-
26-
if RUBY_VERSION == '1.8.7'
27-
# We can't count on the ordering of the hash on 1.8.7...
28-
expect(formatted).to include(%Q{"key"=>#{formatted_time}}, %Q{#{formatted_time}=>"value"}, %Q{"nested"=>{"key"=>#{formatted_time}}})
29-
else
30-
expect(formatted).to eq(%Q{{"key"=>#{formatted_time}, #{formatted_time}=>"value", "nested"=>{"key"=>#{formatted_time}}}})
31-
end
25+
expect(formatted).to eq(%Q{{"key"=>#{formatted_time}, #{formatted_time}=>"value", "nested"=>{"key"=>#{formatted_time}}}})
3226
end
3327
end
3428

35-
unless RUBY_VERSION == '1.8.7' # We can't count on the ordering of the hash on 1.8.7...
36-
context 'with a hash object' do
37-
let(:input) { { :c => "ccc", :a => "aaa", "b" => 'bbb' } }
38-
let(:expected) { '{:a=>"aaa", "b"=>"bbb", :c=>"ccc"}' }
29+
context 'with a hash object' do
30+
let(:input) { { :c => "ccc", :a => "aaa", "b" => 'bbb' } }
31+
let(:expected) { '{:a=>"aaa", "b"=>"bbb", :c=>"ccc"}' }
3932

40-
it 'sorts keys to ensure objects are always displayed the same way' do
41-
formatted = ObjectFormatter.format(input)
42-
expect(formatted).to eq expected
43-
end
33+
it 'sorts keys to ensure objects are always displayed the same way' do
34+
formatted = ObjectFormatter.format(input)
35+
expect(formatted).to eq expected
4436
end
4537
end
4638

@@ -222,14 +214,8 @@ def self.to_s
222214
end
223215
end
224216

225-
if RUBY_VERSION == '1.9.2'
226-
it 'produces an #inspect-like output without object id' do
227-
expect(output).to eq('#<BasicObject:->')
228-
end
229-
else
230-
it "produces an output emulating MRI's #inspect-like output generated by C implementation" do
231-
expect(output).to match(/\A#<BasicObject:0x[0-9a-f]{14,16}>\z/)
232-
end
217+
it "produces an output emulating MRI's #inspect-like output generated by C implementation" do
218+
expect(output).to match(/\A#<BasicObject:0x[0-9a-f]{14,16}>\z/)
233219
end
234220
end
235221

spec/rspec/support/ruby_features_spec.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,10 @@ def ripper_can_parse_source_referencing_keyword_arguments?
112112
require 'ripper'
113113
# It doesn't matter if keyword arguments don't exist.
114114
if Ruby.mri? || Ruby.jruby? || Ruby.truffleruby?
115-
if RUBY_VERSION < '2.0'
116-
true
117-
else
118-
begin
119-
!::Ripper.sexp('def a(**kw_args); end').nil?
120-
rescue NoMethodError
121-
false
122-
end
115+
begin
116+
!::Ripper.sexp('def a(**kw_args); end').nil?
117+
rescue NoMethodError
118+
false
123119
end
124120
end
125121
end

spec/rspec/support/spec/in_sub_process_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module NotIsolated
1010
expect(defined? NotIsolated).to be_nil
1111
end
1212

13-
if Process.respond_to?(:fork) && !(RUBY_PLATFORM == 'java' && RUBY_VERSION == '1.8.7')
13+
if Process.respond_to?(:fork)
1414

1515
it 'returns the result of sub process' do
1616
expect(in_sub_process { :foo }).to eq(:foo)

spec/rspec/support/spec/shell_out_spec.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@
1313
_, _, good_status = shell_out("ruby", "-e", '3 + 3')
1414
expect(good_status.exitstatus).to eq(0)
1515

16-
unless RUBY_VERSION.to_f < 1.9 # except 1.8...
17-
_, _, bad_status = shell_out("ruby", "-e", 'boom')
18-
expect(bad_status.exitstatus).to eq(1)
19-
end
16+
_, _, bad_status = shell_out("ruby", "-e", 'boom')
17+
expect(bad_status.exitstatus).to eq(1)
2018
end
2119

2220
it 'can shell out to ruby with the current load path' do

spec/rspec/support/spec/stderr_splitter_spec.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
# NotImplementedError: pressed?() function is unimplemented on this machine
2929
stderr_methods = stderr.methods.select { |method| stderr.respond_to?(method) }
3030

31-
# On 2.2, there's a weird issue where stderr sometimes responds to `birthtime` and sometimes doesn't...
32-
stderr_methods -= [:birthtime] if RUBY_VERSION =~ /^2\.2/
33-
3431
# No idea why, but on our AppVeyor windows builds it doesn't respond to these...
3532
stderr_methods -= [:close_on_exec?, :close_on_exec=] if RSpec::Support::OS.windows?
3633

spec/rspec/support_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def method_missing(name, *args, &block)
6565
}.to raise_error(NameError)
6666
end
6767

68-
context "for a BasicObject subclass", :if => RUBY_VERSION.to_f > 1.8 do
68+
context "for a BasicObject subclass" do
6969
let(:basic_class) do
7070
Class.new(BasicObject) do
7171
def foo

0 commit comments

Comments
 (0)