Skip to content

Commit

Permalink
Add spec for String#unpack raising ArgumentError on unknown directive
Browse files Browse the repository at this point in the history
  • Loading branch information
Th3-M4jor committed Nov 25, 2024
1 parent 8e0b9e5 commit d26a4fb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/string/unpack/shared/basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
d.should_receive(:to_str).and_return("a"+unpack_format)
"abc".unpack(d).should be_an_instance_of(Array)
end

ruby_version_is "3.3" do
# https://bugs.ruby-lang.org/issues/19150
it 'raise ArgumentError when a directive is unknown' do
-> { "abcdefgh".unpack("a R" + unpack_format) }.should raise_error(ArgumentError)
-> { "abcdefgh".unpack("a 0" + unpack_format) }.should raise_error(ArgumentError)
-> { "abcdefgh".unpack("a :" + unpack_format) }.should raise_error(ArgumentError)
end
end
end

describe :string_unpack_no_platform, shared: true do
Expand Down

0 comments on commit d26a4fb

Please sign in to comment.