Skip to content

Commit 5334048

Browse files
committed
1 parent 313f902 commit 5334048

16 files changed

+96
-29
lines changed

spec/ruby/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ Every example code has a textual description, which presents several advantages:
1818

1919
The specs are written with syntax similar to RSpec 2.
2020
They are run with MSpec, the purpose-built framework for running the Ruby Spec Suite.
21-
For more information, see the [MSpec](http://github.com/ruby/mspec) project.
21+
For more information, see the [MSpec](https://github.com/ruby/mspec) project.
2222

2323
The specs describe the [language syntax](language/), the [core library](core/), the [standard library](library/), the [C API for extensions](optional/capi) and the [command line flags](command_line/).
2424
The language specs are grouped by keyword while the core and standard library specs are grouped by class and method.
2525

2626
ruby/spec is known to be tested in these implementations for every commit:
27-
* [MRI](http://rubyci.org/) on 30 platforms and 4 versions
27+
* [MRI](https://rubyci.org/) on 30 platforms and 4 versions
2828
* [JRuby](https://github.com/jruby/jruby/tree/master/spec/ruby) for both 1.7 and 9.x
2929
* [TruffleRuby](https://github.com/oracle/truffleruby/tree/master/spec/ruby)
3030
* [Opal](https://github.com/opal/opal/tree/master/spec)
@@ -70,7 +70,7 @@ Then move to it:
7070

7171
$ cd spec
7272

73-
Clone [MSpec](http://github.com/ruby/mspec):
73+
Clone [MSpec](https://github.com/ruby/mspec):
7474

7575
$ git clone https://github.com/ruby/mspec.git ../mspec
7676

@@ -152,5 +152,5 @@ This project was originally born from [Rubinius](https://github.com/rubinius/rub
152152
The revision history of these specs is available [here](https://github.com/ruby/spec/blob/2b886623/CHANGES.before-2008-05-10).
153153
These specs were later extracted to their own project, RubySpec, with a specific vision and principles.
154154
At the end of 2014, Brian Shirai, the creator of RubySpec, decided to [end RubySpec](http://rubinius.com/2014/12/31/matz-s-ruby-developers-don-t-use-rubyspec/).
155-
A couple months later, the different repositories were merged and [the project was revived](http://eregon.github.io/rubyspec/2015/07/29/rubyspec-is-reborn.html).
155+
A couple months later, the different repositories were merged and [the project was revived](https://eregon.github.io/rubyspec/2015/07/29/rubyspec-is-reborn.html).
156156
On 12 January 2016, the name was changed to "The Ruby Spec Suite" for clarity and to let the RubySpec ideology rest in peace.

spec/ruby/core/dir/home_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
end
2929
end
3030

31-
platform_is_not :windows, :solaris, :android do
31+
platform_is_not :windows, :solaris, :android, :wasi do
3232
it "returns the named user's home directory, from the user database" do
3333
Dir.home(ENV['USER']).should == `echo ~#{ENV['USER']}`.chomp
3434
end

spec/ruby/core/kernel/define_singleton_method_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,19 @@ def o.define(name)
9696
o.define(:foo) { raise "not used" }
9797
}.should raise_error(ArgumentError)
9898
end
99+
100+
it "always defines the method with public visibility" do
101+
cls = Class.new
102+
def cls.define(name, &block)
103+
private
104+
define_singleton_method(name, &block)
105+
end
106+
107+
-> {
108+
suppress_warning do
109+
cls.define(:foo) { :ok }
110+
end
111+
cls.foo.should == :ok
112+
}.should_not raise_error(NoMethodError)
113+
end
99114
end

spec/ruby/core/kernel/open_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
open(@name, "r") { |f| f.gets }.should == @content
2828
end
2929

30-
platform_is_not :windows do
30+
platform_is_not :windows, :wasi do
3131
it "opens an io when path starts with a pipe" do
3232
@io = open("|date")
3333
begin

spec/ruby/core/kernel/require_relative_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
$LOADED_FEATURES.should include(@abs_path)
208208
end
209209

210-
platform_is_not :windows do
210+
platform_is_not :windows, :wasi do
211211
describe "with symlinks" do
212212
before :each do
213213
@symlink_to_code_dir = tmp("codesymlink")

spec/ruby/core/module/ruby2_keywords_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def kwargs(**kw)
7979
after_usage.should == h
8080
after_usage.should_not.equal?(h)
8181
after_usage.should_not.equal?(marked)
82-
ruby_bug "#18625", ""..."3.2" do
82+
ruby_bug "#18625", ""..."3.3" do # might be fixed in 3.2
8383
Hash.ruby2_keywords_hash?(after_usage).should == false
8484
end
8585
Hash.ruby2_keywords_hash?(marked).should == true

spec/ruby/core/proc/parameters_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,21 @@
2020
proc {|x| }.parameters.first.first.should == :opt
2121
end
2222

23+
ruby_version_is "3.2" do
24+
it "sets the first element of each sub-Array to :req if argument would be required if a lambda if lambda keyword used" do
25+
proc {|x| }.parameters(lambda: true).first.first.should == :req
26+
proc {|y,*x| }.parameters(lambda: true).first.first.should == :req
27+
end
28+
29+
it "regards named parameters in procs as required if lambda keyword used" do
30+
proc {|x| }.parameters(lambda: true).first.first.should == :req
31+
end
32+
33+
it "regards named parameters in lambda as optional if lambda: false keyword used" do
34+
-> x { }.parameters(lambda: false).first.first.should == :opt
35+
end
36+
end
37+
2338
it "regards optional keyword parameters in procs as optional" do
2439
proc {|x: :y| }.parameters.first.first.should == :key
2540
end

spec/ruby/core/struct/new_spec.rb

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,20 @@ def obj.to_str() "Foo" end
6262
-> { Struct.new(:animal, ['chris', 'evan']) }.should raise_error(TypeError)
6363
end
6464

65-
it "raises a TypeError or ArgumentError if passed a Hash with an unknown key" do
66-
# CRuby raises ArgumentError: unknown keyword: :name, but that seems a bug
67-
-> { Struct.new(:animal, { name: 'chris' }) }.should raise_error(StandardError) { |e|
68-
[ArgumentError, TypeError].should.include?(e.class)
69-
}
65+
ruby_version_is ""..."3.2" do
66+
it "raises a TypeError or ArgumentError if passed a Hash with an unknown key" do
67+
# CRuby < 3.2 raises ArgumentError: unknown keyword: :name, but that seems a bug:
68+
# https://bugs.ruby-lang.org/issues/18632
69+
-> { Struct.new(:animal, { name: 'chris' }) }.should raise_error(StandardError) { |e|
70+
[ArgumentError, TypeError].should.include?(e.class)
71+
}
72+
end
73+
end
74+
75+
ruby_version_is "3.2" do
76+
it "raises a TypeError if passed a Hash with an unknown key" do
77+
-> { Struct.new(:animal, { name: 'chris' }) }.should raise_error(TypeError)
78+
end
7079
end
7180

7281
it "raises ArgumentError when there is a duplicate member" do

spec/ruby/language/keyword_arguments_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def m(*args, **kwargs)
125125
end
126126

127127
it "works with -> (*args, **kwargs) {}" do
128-
m = -> (*args, **kwargs) do
128+
m = -> *args, **kwargs do
129129
target(*args, **kwargs)
130130
end
131131

@@ -261,8 +261,8 @@ def y(args)
261261
yield(*args)
262262
end
263263

264-
ruby2_keywords def m(*args)
265-
y(args, &-> (*args, **kwargs) { target(*args, **kwargs) })
264+
ruby2_keywords def m(*outer_args)
265+
y(outer_args, &-> *args, **kwargs { target(*args, **kwargs) })
266266
end
267267
end
268268

spec/ruby/language/predefined_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,8 @@ def obj.foo2; yield; end
854854
end
855855

856856
it "default $LOAD_PATH entries until sitelibdir included have @gem_prelude_index set" do
857+
skip "no sense in ruby itself" if MSpecScript.instance_variable_defined?(:@testing_ruby)
858+
857859
$:.should.include?(RbConfig::CONFIG['sitelibdir'])
858860
idx = $:.index(RbConfig::CONFIG['sitelibdir'])
859861

0 commit comments

Comments
 (0)