Skip to content

Commit 4dce466

Browse files
committed
Update Mysql2::Result spec for Ruby 3.1
Ruby 3.1 immediately raise a TypeError if you try to instantiate a class that doesn't have an allocator, which is what we want anyways.
1 parent 6652da2 commit 4dce466

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

spec/mysql2/result_spec.rb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@
66
end
77

88
it "should raise a TypeError exception when it doesn't wrap a result set" do
9-
r = Mysql2::Result.new
10-
expect { r.count }.to raise_error(TypeError)
11-
expect { r.fields }.to raise_error(TypeError)
12-
expect { r.field_types }.to raise_error(TypeError)
13-
expect { r.size }.to raise_error(TypeError)
14-
expect { r.each }.to raise_error(TypeError)
9+
if RUBY_VERSION >= "3.1"
10+
expect { Mysql2::Result.new }.to raise_error(TypeError)
11+
expect { Mysql2::Result.allocate }.to raise_error(TypeError)
12+
else
13+
r = Mysql2::Result.new
14+
expect { r.count }.to raise_error(TypeError)
15+
expect { r.fields }.to raise_error(TypeError)
16+
expect { r.field_types }.to raise_error(TypeError)
17+
expect { r.size }.to raise_error(TypeError)
18+
expect { r.each }.to raise_error(TypeError)
19+
end
1520
end
1621

1722
it "should have included Enumerable" do

0 commit comments

Comments
 (0)