Skip to content

Commit 0e00805

Browse files
committed
[GR-14806] Update specs
PullRequest: truffleruby/3672
2 parents 8ceb8da + fc41605 commit 0e00805

File tree

203 files changed

+648
-165
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

203 files changed

+648
-165
lines changed

spec/mspec/spec/helpers/ruby_exe_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class RubyExeSpecs
145145
stub_const 'RUBY_EXE', 'ruby_spec_exe -w -Q'
146146

147147
@script = RubyExeSpecs.new
148-
allow(@script).to receive(:`).and_return('OUTPUT')
148+
allow(IO).to receive(:popen).and_return('OUTPUT')
149149

150150
status_successful = double(Process::Status, exited?: true, exitstatus: 0)
151151
allow(Process).to receive(:last_status).and_return(status_successful)
@@ -155,7 +155,7 @@ class RubyExeSpecs
155155
code = "code"
156156
options = {}
157157
output = "output"
158-
allow(@script).to receive(:`).and_return(output)
158+
expect(IO).to receive(:popen).and_return(output)
159159

160160
expect(@script.ruby_exe(code, options)).to eq output
161161
end
@@ -168,7 +168,7 @@ class RubyExeSpecs
168168
code = "code"
169169
options = {}
170170
expect(@script).to receive(:ruby_cmd).and_return("ruby_cmd")
171-
expect(@script).to receive(:`).with("ruby_cmd")
171+
expect(IO).to receive(:popen).with("ruby_cmd")
172172
@script.ruby_exe(code, options)
173173
end
174174

@@ -227,7 +227,7 @@ class RubyExeSpecs
227227
expect(ENV).to receive(:[]=).with("ABC", "xyz")
228228
expect(ENV).to receive(:[]=).with("ABC", "123")
229229

230-
expect(@script).to receive(:`).and_raise(Exception)
230+
expect(IO).to receive(:popen).and_raise(Exception)
231231
expect do
232232
@script.ruby_exe nil, :env => { :ABC => "xyz" }
233233
end.to raise_error(Exception)
@@ -248,7 +248,7 @@ class RubyExeSpecs
248248

249249
it "does not raise exception when command ends with expected status" do
250250
output = "output"
251-
allow(@script).to receive(:`).and_return(output)
251+
expect(IO).to receive(:popen).and_return(output)
252252

253253
expect(@script.ruby_exe("path", exit_status: 4)).to eq output
254254
end
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env ruby
2+
3+
# This script is used to check that each *_spec.rb file has
4+
# a relative_require for spec_helper which should live higher
5+
# up in the ruby/spec repo directory tree.
6+
#
7+
# Prints errors to $stderr and returns a non-zero exit code when
8+
# errors are found.
9+
#
10+
# Related to https://github.com/ruby/spec/pull/992
11+
12+
def check_file(fn)
13+
File.foreach(fn) do |line|
14+
return $1 if line =~ /^\s*require_relative\s*['"](.*spec_helper)['"]/
15+
end
16+
nil
17+
end
18+
19+
rootdir = ARGV[0] || "."
20+
fglob = File.join(rootdir, "**", "*_spec.rb")
21+
specfiles = Dir.glob(fglob)
22+
raise "No spec files found in #{fglob.inspect}. Give an argument to specify the root-directory of ruby/spec" if specfiles.empty?
23+
24+
errors = 0
25+
specfiles.sort.each do |fn|
26+
result = check_file(fn)
27+
if result.nil?
28+
warn "Missing require_relative for *spec_helper for file: #{fn}"
29+
errors += 1
30+
end
31+
end
32+
33+
puts "# Found #{errors} files with require_relative spec_helper issues."
34+
exit 1 if errors > 0

spec/ruby/core/array/all_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require_relative 'shared/iterable_and_tolerating_size_increasing'
33

44
describe "Array#all?" do
5-
@value_to_return = -> (_) { true }
5+
@value_to_return = -> _ { true }
66
it_behaves_like :array_iterable_and_tolerating_size_increasing, :all?
77

88
it "ignores the block if there is an argument" do

spec/ruby/core/array/any_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
end
2121

2222
describe 'with a block given' do
23-
@value_to_return = -> (_) { false }
23+
@value_to_return = -> _ { false }
2424
it_behaves_like :array_iterable_and_tolerating_size_increasing, :any?
2525

2626
it 'is false if the array is empty' do

spec/ruby/core/array/delete_if_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,6 @@
7777
it_behaves_like :enumeratorized_with_origin_size, :delete_if, [1,2,3]
7878
it_behaves_like :delete_if, :delete_if
7979

80-
@value_to_return = -> (_) { false }
80+
@value_to_return = -> _ { false }
8181
it_behaves_like :array_iterable_and_tolerating_size_increasing, :delete_if
8282
end

spec/ruby/core/array/drop_while_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require_relative 'shared/iterable_and_tolerating_size_increasing'
44

55
describe "Array#drop_while" do
6-
@value_to_return = -> (_) { true }
6+
@value_to_return = -> _ { true }
77
it_behaves_like :array_iterable_and_tolerating_size_increasing, :drop_while
88

99
it "removes elements from the start of the array while the block evaluates to true" do

spec/ruby/core/array/each_index_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# Modifying a collection while the contents are being iterated
77
# gives undefined behavior. See
8-
# http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/23633
8+
# https://blade.ruby-lang.org/ruby-core/23633
99

1010
describe "Array#each_index" do
1111
before :each do

spec/ruby/core/array/fill_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211
[1, 2, 3, 4, 5].fill(-2, -2, &@never_passed).should == [1, 2, 3, 4, 5]
212212
end
213213

214-
# See: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/17481
214+
# See: https://blade.ruby-lang.org/ruby-core/17481
215215
it "does not raise an exception if the given length is negative and its absolute value does not exceed the index" do
216216
-> { [1, 2, 3, 4].fill('a', 3, -1)}.should_not raise_error(ArgumentError)
217217
-> { [1, 2, 3, 4].fill('a', 3, -2)}.should_not raise_error(ArgumentError)

spec/ruby/core/array/none_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require_relative 'shared/iterable_and_tolerating_size_increasing'
33

44
describe "Array#none?" do
5-
@value_to_return = -> (_) { false }
5+
@value_to_return = -> _ { false }
66
it_behaves_like :array_iterable_and_tolerating_size_increasing, :none?
77

88
it "ignores the block if there is an argument" do

spec/ruby/core/array/one_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require_relative 'shared/iterable_and_tolerating_size_increasing'
33

44
describe "Array#one?" do
5-
@value_to_return = -> (_) { false }
5+
@value_to_return = -> _ { false }
66
it_behaves_like :array_iterable_and_tolerating_size_increasing, :one?
77

88
it "ignores the block if there is an argument" do

0 commit comments

Comments
 (0)