Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GR-14806] Update specs to ruby/spec@affef93 #3782

Merged
merged 4 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions spec/mspec/lib/mspec/commands/mkspec.rb
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env ruby

require 'rbconfig'
require 'mspec/version'
require 'mspec/utils/options'
Expand Down
4 changes: 0 additions & 4 deletions spec/mspec/lib/mspec/commands/mspec-ci.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#!/usr/bin/env ruby

$:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')

require 'mspec/version'
require 'mspec/utils/options'
require 'mspec/utils/script'
Expand Down
4 changes: 0 additions & 4 deletions spec/mspec/lib/mspec/commands/mspec-run.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#!/usr/bin/env ruby

$:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')

require 'mspec/version'
require 'mspec/utils/options'
require 'mspec/utils/script'
Expand Down
2 changes: 0 additions & 2 deletions spec/mspec/lib/mspec/commands/mspec-tag.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env ruby

require 'mspec/version'
require 'mspec/utils/options'
require 'mspec/utils/script'
Expand Down
2 changes: 0 additions & 2 deletions spec/mspec/lib/mspec/commands/mspec.rb
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env ruby

require 'mspec/version'
require 'mspec/utils/options'
require 'mspec/utils/script'
Expand Down
3 changes: 0 additions & 3 deletions spec/ruby/core/binding/fixtures/irb.rb

This file was deleted.

2 changes: 1 addition & 1 deletion spec/ruby/core/binding/shared/clone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
end

it "copies the finalizer" do
code = <<-RUBY
code = <<-'RUBY'
obj = binding
ObjectSpace.define_finalizer(obj, Proc.new { STDOUT.write "finalized\n" })
Expand Down
38 changes: 20 additions & 18 deletions spec/ruby/core/dir/chdir_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,27 +177,29 @@ def to_str; DirSpecs.mock_dir; end
dir.close
end

it "does not raise an Errno::ENOENT if the original directory no longer exists" do
dir_name1 = tmp('testdir1')
dir_name2 = tmp('testdir2')
Dir.should_not.exist?(dir_name1)
Dir.should_not.exist?(dir_name2)
Dir.mkdir dir_name1
Dir.mkdir dir_name2

dir2 = Dir.new(dir_name2)

begin
Dir.chdir(dir_name1) do
dir2.chdir { Dir.unlink dir_name1 }
platform_is_not :windows do
it "does not raise an Errno::ENOENT if the original directory no longer exists" do
dir_name1 = tmp('testdir1')
dir_name2 = tmp('testdir2')
Dir.should_not.exist?(dir_name1)
Dir.should_not.exist?(dir_name2)
Dir.mkdir dir_name1
Dir.mkdir dir_name2

dir2 = Dir.new(dir_name2)

begin
Dir.chdir(dir_name1) do
dir2.chdir { Dir.unlink dir_name1 }
end
Dir.pwd.should == @original
ensure
Dir.unlink dir_name1 if Dir.exist?(dir_name1)
Dir.unlink dir_name2 if Dir.exist?(dir_name2)
end
Dir.pwd.should == @original
ensure
Dir.unlink dir_name1 if Dir.exist?(dir_name1)
Dir.unlink dir_name2 if Dir.exist?(dir_name2)
dir2.close
end
ensure
dir2.close
end

it "always returns to the original directory when given a block" do
Expand Down
2 changes: 2 additions & 0 deletions spec/ruby/core/dir/for_fd_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require_relative '../../spec_helper'
require_relative 'fixtures/common'

quarantine! do # leads to "Errno::EBADF: Bad file descriptor - closedir" in DirSpecs.delete_mock_dirs
ruby_version_is '3.3' do
guard -> { Dir.respond_to? :for_fd } do
describe "Dir.for_fd" do
Expand Down Expand Up @@ -75,3 +76,4 @@
end
end
end
end
2 changes: 1 addition & 1 deletion spec/ruby/core/enumerable/collect_concat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
require_relative 'shared/collect_concat'

describe "Enumerable#collect_concat" do
it_behaves_like :enumerable_collect_concat , :collect_concat
it_behaves_like :enumerable_collect_concat, :collect_concat
end
2 changes: 1 addition & 1 deletion spec/ruby/core/enumerable/collect_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
require_relative 'shared/collect'

describe "Enumerable#collect" do
it_behaves_like :enumerable_collect , :collect
it_behaves_like :enumerable_collect, :collect
end
2 changes: 1 addition & 1 deletion spec/ruby/core/enumerable/detect_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
require_relative 'shared/find'

describe "Enumerable#detect" do
it_behaves_like :enumerable_find , :detect
it_behaves_like :enumerable_find, :detect
end
2 changes: 1 addition & 1 deletion spec/ruby/core/enumerable/entries_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
require_relative 'shared/entries'

describe "Enumerable#entries" do
it_behaves_like :enumerable_entries , :entries
it_behaves_like :enumerable_entries, :entries
end
2 changes: 1 addition & 1 deletion spec/ruby/core/enumerable/filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
require_relative 'shared/find_all'

describe "Enumerable#filter" do
it_behaves_like(:enumerable_find_all , :filter)
it_behaves_like(:enumerable_find_all, :filter)
end
2 changes: 1 addition & 1 deletion spec/ruby/core/enumerable/find_all_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
require_relative 'shared/find_all'

describe "Enumerable#find_all" do
it_behaves_like :enumerable_find_all , :find_all
it_behaves_like :enumerable_find_all, :find_all
end
2 changes: 1 addition & 1 deletion spec/ruby/core/enumerable/find_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
require_relative 'shared/find'

describe "Enumerable#find" do
it_behaves_like :enumerable_find , :find
it_behaves_like :enumerable_find, :find
end
2 changes: 1 addition & 1 deletion spec/ruby/core/enumerable/flat_map_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
require_relative 'shared/collect_concat'

describe "Enumerable#flat_map" do
it_behaves_like :enumerable_collect_concat , :flat_map
it_behaves_like :enumerable_collect_concat, :flat_map
end
2 changes: 1 addition & 1 deletion spec/ruby/core/enumerable/map_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
require_relative 'shared/collect'

describe "Enumerable#map" do
it_behaves_like :enumerable_collect , :map
it_behaves_like :enumerable_collect, :map
end
2 changes: 1 addition & 1 deletion spec/ruby/core/enumerable/select_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
require_relative 'shared/find_all'

describe "Enumerable#select" do
it_behaves_like :enumerable_find_all , :select
it_behaves_like :enumerable_find_all, :select
end
2 changes: 1 addition & 1 deletion spec/ruby/core/enumerable/to_a_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
require_relative 'shared/entries'

describe "Enumerable#to_a" do
it_behaves_like :enumerable_entries , :to_a
it_behaves_like :enumerable_entries, :to_a
end
27 changes: 25 additions & 2 deletions spec/ruby/core/fiber/storage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,38 @@
key = :"#{self.class.name}#.#{self.object_id}"
Fiber.new { Fiber[key] = 42; Fiber[key] }.resume.should == 42
end

it "can't use invalid keys" do
invalid_keys = [Object.new, 12]
invalid_keys.each do |key|
-> { Fiber[key] }.should raise_error(TypeError)
end
end
end

ruby_bug "#20978", "3.2"..."3.4" do
it "can use keys as strings" do
key = Object.new
def key.to_str; "Foo"; end
Fiber[key] = 42
Fiber["Foo"].should == 42
Fiber.new { Fiber[key] = 42; Fiber["Foo"] }.resume.should == 42
end

it "converts a String key into a Symbol" do
Fiber.new { Fiber["key"] = 42; Fiber[:key] }.resume.should == 42
Fiber.new { Fiber[:key] = 42; Fiber["key"] }.resume.should == 42
end

it "can use any object that responds to #to_str as a key" do
key = mock("key")
key.should_receive(:to_str).twice.and_return("key")
Fiber.new { Fiber[key] = 42; Fiber[key] }.resume.should == 42
end
end

it "does not call #to_sym on the key" do
key = mock("key")
key.should_not_receive(:to_sym)
-> { Fiber[key] }.should raise_error(TypeError)
end

it "can access the storage of the parent fiber" do
Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/core/kernel/is_a_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
require_relative 'shared/kind_of'

describe "Kernel#is_a?" do
it_behaves_like :kernel_kind_of , :is_a?
it_behaves_like :kernel_kind_of, :is_a?
end
2 changes: 1 addition & 1 deletion spec/ruby/core/kernel/kind_of_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
require_relative 'shared/kind_of'

describe "Kernel#kind_of?" do
it_behaves_like :kernel_kind_of , :kind_of?
it_behaves_like :kernel_kind_of, :kind_of?
end
2 changes: 1 addition & 1 deletion spec/ruby/core/method/shared/dup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
end

it "copies the finalizer" do
code = <<-RUBY
code = <<-'RUBY'
obj = Object.new.method(:method)
ObjectSpace.define_finalizer(obj, Proc.new { STDOUT.write "finalized\n" })
Expand Down
16 changes: 11 additions & 5 deletions spec/ruby/core/method/source_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@
end

it "sets the first value to the path of the file in which the method was defined" do
file = @method.source_location.first
file = @method.source_location[0]
file.should be_an_instance_of(String)
file.should == File.realpath('fixtures/classes.rb', __dir__)
end

it "sets the last value to an Integer representing the line on which the method was defined" do
line = @method.source_location.last
line = @method.source_location[1]
line.should be_an_instance_of(Integer)
line.should == 5
end

it "returns the last place the method was defined" do
MethodSpecs::SourceLocation.method(:redefined).source_location.last.should == 13
MethodSpecs::SourceLocation.method(:redefined).source_location[1].should == 13
end

it "returns the location of the original method even if it was aliased" do
MethodSpecs::SourceLocation.new.method(:aka).source_location.last.should == 17
MethodSpecs::SourceLocation.new.method(:aka).source_location[1].should == 17
end

it "works for methods defined with a block" do
Expand Down Expand Up @@ -108,7 +108,13 @@ def f
c = Class.new do
eval('def self.m; end', nil, "foo", 100)
end
c.method(:m).source_location.should == ["foo", 100]
location = c.method(:m).source_location
ruby_version_is(""..."3.5") do
location.should == ["foo", 100]
end
ruby_version_is("3.5") do
location.should == ["foo", 100, 0, 100, 15]
end
end

describe "for a Method generated by respond_to_missing?" do
Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/core/objectspace/define_finalizer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def finalizer(zelf)
end

it "allows multiple finalizers with different 'callables' to be defined" do
code = <<-RUBY
code = <<-'RUBY'
obj = Object.new
ObjectSpace.define_finalizer(obj, Proc.new { STDOUT.write "finalized1\n" })
Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/core/proc/shared/dup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
end

it "copies the finalizer" do
code = <<-RUBY
code = <<-'RUBY'
obj = Proc.new { }
ObjectSpace.define_finalizer(obj, Proc.new { STDOUT.write "finalized\n" })
Expand Down
Loading
Loading