Skip to content

Commit

Permalink
Use Object instead of String for invalid maxlen/offset values
Browse files Browse the repository at this point in the history
This way the error message is consistent between different Ruby
platforms.
  • Loading branch information
herwinw committed Sep 27, 2023
1 parent b11f996 commit 5d613a8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/io/pread_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@
end

it "raises TypeError if maxlen is not an Integer and cannot be coerced into Integer" do
-> { @file.pread("maxlen", 0) }.should raise_error(TypeError, 'no implicit conversion from string')
maxlen = Object.new
-> { @file.pread(maxlen, 0) }.should raise_error(TypeError, 'no implicit conversion of Object into Integer')
end

it "raises TypeError if offset is not an Integer and cannot be coerced into Integer" do
-> { @file.pread(4, "offset") }.should raise_error(TypeError, 'no implicit conversion of String into Integer')
offset = Object.new
-> { @file.pread(4, offset) }.should raise_error(TypeError, 'no implicit conversion of Object into Integer')
end

it "raises ArgumentError for negative values of maxlen" do
Expand Down

0 comments on commit 5d613a8

Please sign in to comment.