Skip to content

Commit d6ec087

Browse files
committed
1 parent 0a9b0c2 commit d6ec087

File tree

177 files changed

+2741
-3372
lines changed

Some content is hidden

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

177 files changed

+2741
-3372
lines changed

spec/ruby/.travis.yml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,18 @@ language: ruby
33
install:
44
- git clone https://github.com/ruby/mspec.git ../mspec
55
script:
6-
- ../mspec/bin/mspec $MSPEC_OPTS
6+
- CHECK_LEAKS=true ../mspec/bin/mspec
77
matrix:
88
include:
9+
- name: Running each spec twice
10+
rvm: 2.5.5
11+
script:
12+
- CHECK_LEAKS=true ../mspec/bin/mspec -R2 -ff
13+
- rvm: 2.4.6
914
- rvm: 2.5.5
10-
env: MSPEC_OPTS="-R2 -ff"
11-
- rvm: 2.3.8
12-
- rvm: 2.4.5
13-
env: CHECK_LEAKS=true
14-
- rvm: 2.5.5
15-
env: CHECK_LEAKS=true
16-
- rvm: 2.6.2
17-
env: CHECK_LEAKS=true
18-
- env: RUBOCOP=true
19-
rvm: 2.4.5
15+
- rvm: 2.6.3
16+
- name: RuboCop Lint Checks
17+
rvm: 2.4.6
2018
script:
2119
- gem install rubocop:0.61.0
2220
- rubocop

spec/ruby/CONTRIBUTING.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@ end
144144

145145

146146
# Combining guards
147-
guard -> { platform_is :windows and ruby_version_is ""..."2.3" } do
148-
# Windows and RUBY_VERSION < 2.3
147+
guard -> { platform_is :windows and ruby_version_is ""..."2.5" } do
148+
# Windows and RUBY_VERSION < 2.5
149149
end
150150

151-
guard_not -> { platform_is :windows and ruby_version_is ""..."2.3" } do
151+
guard_not -> { platform_is :windows and ruby_version_is ""..."2.5" } do
152152
# The opposite
153153
end
154154

@@ -170,20 +170,20 @@ If an implementation does not support some feature, simply tag the related specs
170170

171171
### Shared Specs
172172

173-
Often throughout Ruby, identical functionality is used by different methods and modules. In order
173+
Often throughout Ruby, identical functionality is used by different methods and modules. In order
174174
to avoid duplication of specs, we have shared specs that are re-used in other specs. The use is a
175175
bit tricky however, so let's go over it.
176176

177177
Commonly, if a shared spec is only reused within its own module, the shared spec will live within a
178-
shared directory inside that module's directory. For example, the `core/hash/shared/key.rb` spec is
178+
shared directory inside that module's directory. For example, the `core/hash/shared/key.rb` spec is
179179
only used by `Hash` specs, and so it lives inside `core/hash/shared/`.
180180

181181
When a shared spec is used across multiple modules or classes, it lives within the `shared/` directory.
182-
An example of this is the `shared/file/socket.rb` which is used by `core/file/socket_spec.rb`,
182+
An example of this is the `shared/file/socket.rb` which is used by `core/file/socket_spec.rb`,
183183
`core/filetest/socket_spec.rb`, and `core/file/state/socket_spec.rb` and so it lives in the root `shared/`.
184184

185185
Defining a shared spec involves adding a `shared: true` option to the top-level `describe` block. This
186-
will signal not to run the specs directly by the runner. Shared specs have access to two instance
186+
will signal not to run the specs directly by the runner. Shared specs have access to two instance
187187
variables from the implementor spec: `@method` and `@object`, which the implementor spec will pass in.
188188

189189
Here's an example of a snippet of a shared spec and two specs which integrates it:

spec/ruby/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ ruby/spec is known to be tested in these implementations for every commit:
2828
* [TruffleRuby](https://github.com/oracle/truffleruby/tree/master/spec/ruby)
2929
* [Opal](https://github.com/opal/opal/tree/master/spec)
3030

31-
ruby/spec describes the behavior of Ruby 2.3 and more recent Ruby versions.
32-
More precisely, every latest stable MRI release should [pass](https://travis-ci.org/ruby/spec) all specs of ruby/spec (2.3.x, 2.4.x, 2.5.x, 2.6.x, etc), and those are tested in TravisCI.
31+
ruby/spec describes the behavior of Ruby 2.4 and more recent Ruby versions.
32+
More precisely, every latest stable MRI release should [pass](https://travis-ci.org/ruby/spec) all specs of ruby/spec (2.4.x, 2.5.x, 2.6.x, etc), and those are tested in TravisCI.
3333

3434
The specs are synchronized both ways around once a month by @eregon between ruby/spec, MRI, JRuby and TruffleRuby.
3535
Each of these repositories has a full copy of the specs under `spec/ruby` to ease editing specs.
@@ -49,6 +49,7 @@ For older specs try these commits:
4949
* Ruby 2.0.0-p647 - [Suite](https://github.com/ruby/spec/commit/245862558761d5abc676843ef74f86c9bcc8ea8d) using [MSpec](https://github.com/ruby/mspec/commit/f90efa068791064f955de7a843e96e2d7d3041c2) (may encounter 2 failures)
5050
* Ruby 2.1.9 - [Suite](https://github.com/ruby/spec/commit/f029e65241374386077ac500add557ae65069b55) using [MSpec](https://github.com/ruby/mspec/commit/55568ea3918c6380e64db8c567d732fa5781efed)
5151
* Ruby 2.2.10 - [Suite](https://github.com/ruby/spec/commit/cbaa0e412270c944df0c2532fc500c920dba0e92) using [MSpec](https://github.com/ruby/mspec/commit/d84d7668449e96856c5f6bac8cb1526b6d357ce3)
52+
* Ruby 2.3.8 - [Suite](https://github.com/ruby/spec/commit/dc733114d8ae66a3368ba3a98422c50147a76ba5) using [MSpec](https://github.com/ruby/mspec/commit/4599bc195fb109f2a482a01c32a7d659518369ea)
5253

5354
### Running the specs
5455

spec/ruby/command_line/feature_spec.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,6 @@
3737
ruby_exe("p 'foo'.frozen?", options: "--disable-frozen-string-literal").chomp.should == "false"
3838
end
3939

40-
ruby_version_is "2.6" do
41-
it "can be used with jit" do
42-
ruby_exe("p RubyVM::MJIT.enabled?", options: "--enable=jit").chomp.should == "true"
43-
ruby_exe("p RubyVM::MJIT.enabled?", options: "--disable=jit").chomp.should == "false"
44-
ruby_exe("p RubyVM::MJIT.enabled?", options: "--enable-jit").chomp.should == "true"
45-
ruby_exe("p RubyVM::MJIT.enabled?", options: "--disable-jit").chomp.should == "false"
46-
end
47-
end
48-
4940
it "can be used with all" do
5041
e = "p [defined?(Gem), defined?(DidYouMean), $VERBOSE, 'foo'.frozen?]"
5142
env = {'RUBYOPT' => '-w'}

spec/ruby/core/array/concat_spec.rb

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -110,23 +110,21 @@
110110
ary.concat([5, 6]).should == [4, 5, 6]
111111
end
112112

113-
ruby_version_is "2.4" do
114-
it "takes multiple arguments" do
115-
ary = [1, 2]
116-
ary.concat [3, 4]
117-
ary.should == [1, 2, 3, 4]
118-
end
119-
120-
it "concatenates the initial value when given arguments contain 2 self" do
121-
ary = [1, 2]
122-
ary.concat ary, ary
123-
ary.should == [1, 2, 1, 2, 1, 2]
124-
end
125-
126-
it "returns self when given no arguments" do
127-
ary = [1, 2]
128-
ary.concat.should equal(ary)
129-
ary.should == [1, 2]
130-
end
113+
it "takes multiple arguments" do
114+
ary = [1, 2]
115+
ary.concat [3, 4]
116+
ary.should == [1, 2, 3, 4]
117+
end
118+
119+
it "concatenates the initial value when given arguments contain 2 self" do
120+
ary = [1, 2]
121+
ary.concat ary, ary
122+
ary.should == [1, 2, 1, 2, 1, 2]
123+
end
124+
125+
it "returns self when given no arguments" do
126+
ary = [1, 2]
127+
ary.concat.should equal(ary)
128+
ary.should == [1, 2]
131129
end
132130
end

spec/ruby/core/array/join_spec.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@
3838
end
3939

4040
after :each do
41-
$, = @before_separator
41+
suppress_warning {$, = @before_separator}
4242
end
4343

4444
it "separates elements with default separator when the passed separator is nil" do
45-
$, = "_"
46-
[1, 2, 3].join(nil).should == '1_2_3'
45+
suppress_warning {
46+
$, = "_"
47+
[1, 2, 3].join(nil).should == '1_2_3'
48+
}
4749
end
4850
end

spec/ruby/core/array/max_spec.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
require_relative '../../spec_helper'
22

33
describe "Array#max" do
4-
ruby_version_is "2.4" do
5-
it "is defined on Array" do
6-
[1].method(:max).owner.should equal Array
7-
end
4+
it "is defined on Array" do
5+
[1].method(:max).owner.should equal Array
86
end
97

108
it "returns nil with no values" do

spec/ruby/core/array/min_spec.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
require_relative '../../spec_helper'
22

33
describe "Array#min" do
4-
ruby_version_is "2.4" do
5-
it "is defined on Array" do
6-
[1].method(:max).owner.should equal Array
7-
end
4+
it "is defined on Array" do
5+
[1].method(:max).owner.should equal Array
86
end
97

108
it "returns nil with no values" do

spec/ruby/core/array/pack/buffer_spec.rb

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,49 @@
22

33
require_relative '../../../spec_helper'
44

5-
ruby_version_is '2.4' do
6-
describe "Array#pack with :buffer option" do
7-
it "returns specified buffer" do
8-
n = [ 65, 66, 67 ]
9-
buffer = " "*3
10-
result = n.pack("ccc", buffer: buffer) #=> "ABC"
11-
result.should equal(buffer)
12-
end
5+
describe "Array#pack with :buffer option" do
6+
it "returns specified buffer" do
7+
n = [ 65, 66, 67 ]
8+
buffer = " "*3
9+
result = n.pack("ccc", buffer: buffer) #=> "ABC"
10+
result.should equal(buffer)
11+
end
1312

14-
it "adds result at the end of buffer content" do
15-
n = [ 65, 66, 67 ] # result without buffer is "ABC"
13+
it "adds result at the end of buffer content" do
14+
n = [ 65, 66, 67 ] # result without buffer is "ABC"
1615

17-
buffer = ""
18-
n.pack("ccc", buffer: buffer).should == "ABC"
16+
buffer = ""
17+
n.pack("ccc", buffer: buffer).should == "ABC"
1918

20-
buffer = "123"
21-
n.pack("ccc", buffer: buffer).should == "123ABC"
19+
buffer = "123"
20+
n.pack("ccc", buffer: buffer).should == "123ABC"
21+
22+
buffer = "12345"
23+
n.pack("ccc", buffer: buffer).should == "12345ABC"
24+
end
2225

23-
buffer = "12345"
24-
n.pack("ccc", buffer: buffer).should == "12345ABC"
26+
it "raises TypeError exception if buffer is not String" do
27+
lambda { [65].pack("ccc", buffer: []) }.should raise_error(
28+
TypeError, "buffer must be String, not Array")
29+
end
30+
31+
context "offset (@) is specified" do
32+
it 'keeps buffer content if it is longer than offset' do
33+
n = [ 65, 66, 67 ]
34+
buffer = "123456"
35+
n.pack("@3ccc", buffer: buffer).should == "123ABC"
2536
end
2637

27-
it "raises TypeError exception if buffer is not String" do
28-
lambda { [65].pack("ccc", buffer: []) }.should raise_error(
29-
TypeError, "buffer must be String, not Array")
38+
it "fills the gap with \\0 if buffer content is shorter than offset" do
39+
n = [ 65, 66, 67 ]
40+
buffer = "123"
41+
n.pack("@6ccc", buffer: buffer).should == "123\0\0\0ABC"
3042
end
3143

32-
context "offset (@) is specified" do
33-
it 'keeps buffer content if it is longer than offset' do
34-
n = [ 65, 66, 67 ]
35-
buffer = "123456"
36-
n.pack("@3ccc", buffer: buffer).should == "123ABC"
37-
end
38-
39-
it "fills the gap with \\0 if buffer content is shorter than offset" do
40-
n = [ 65, 66, 67 ]
41-
buffer = "123"
42-
n.pack("@6ccc", buffer: buffer).should == "123\0\0\0ABC"
43-
end
44-
45-
it 'does not keep buffer content if it is longer than offset + result' do
46-
n = [ 65, 66, 67 ]
47-
buffer = "1234567890"
48-
n.pack("@3ccc", buffer: buffer).should == "123ABC"
49-
end
44+
it 'does not keep buffer content if it is longer than offset + result' do
45+
n = [ 65, 66, 67 ]
46+
buffer = "1234567890"
47+
n.pack("@3ccc", buffer: buffer).should == "123ABC"
5048
end
5149
end
5250
end

spec/ruby/core/array/reject_spec.rb

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,22 +121,20 @@
121121
a.should == [1, 2, 3]
122122
end
123123

124-
ruby_version_is "2.4" do
125-
it "only removes elements for which the block returns true, keeping the element which raised an error." do
126-
a = [1, 2, 3, 4]
127-
begin
128-
a.reject! do |x|
129-
case x
130-
when 2 then true
131-
when 3 then raise StandardError, 'Oops'
132-
else false
133-
end
124+
it "only removes elements for which the block returns true, keeping the element which raised an error." do
125+
a = [1, 2, 3, 4]
126+
begin
127+
a.reject! do |x|
128+
case x
129+
when 2 then true
130+
when 3 then raise StandardError, 'Oops'
131+
else false
134132
end
135-
rescue StandardError
136133
end
137-
138-
a.should == [1, 3, 4]
134+
rescue StandardError
139135
end
136+
137+
a.should == [1, 3, 4]
140138
end
141139

142140
it_behaves_like :enumeratorize, :reject!

0 commit comments

Comments
 (0)