diff options
Diffstat (limited to 'spec/ruby/core/array/pack/shared/unicode.rb')
| -rw-r--r-- | spec/ruby/core/array/pack/shared/unicode.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/spec/ruby/core/array/pack/shared/unicode.rb b/spec/ruby/core/array/pack/shared/unicode.rb index dd0f8b38aa..58ba8a8b23 100644 --- a/spec/ruby/core/array/pack/shared/unicode.rb +++ b/spec/ruby/core/array/pack/shared/unicode.rb @@ -26,7 +26,7 @@ describe :array_pack_unicode, shared: true do it "constructs strings with valid encodings" do str = [0x85].pack("U*") str.should == "\xc2\x85" - str.valid_encoding?.should be_true + str.valid_encoding?.should == true end it "encodes values larger than UTF-8 max codepoints" do @@ -64,11 +64,13 @@ describe :array_pack_unicode, shared: true do it "raises a TypeError if #to_int does not return an Integer" do obj = mock('to_int') obj.should_receive(:to_int).and_return("5") - -> { [obj].pack("U") }.should raise_error(TypeError) + -> { [obj].pack("U") }.should.raise(TypeError) end - it "ignores NULL bytes between directives" do - [1, 2, 3].pack("U\x00U").should == "\x01\x02" + it "raise ArgumentError for NULL bytes between directives" do + -> { + [1, 2, 3].pack("U\x00U") + }.should.raise(ArgumentError, /unknown pack directive/) end it "ignores spaces between directives" do @@ -76,11 +78,11 @@ describe :array_pack_unicode, shared: true do end it "raises a RangeError if passed a negative number" do - -> { [-1].pack("U") }.should raise_error(RangeError) + -> { [-1].pack("U") }.should.raise(RangeError) end it "raises a RangeError if passed a number larger than an unsigned 32-bit integer" do - -> { [2**32].pack("U") }.should raise_error(RangeError) + -> { [2**32].pack("U") }.should.raise(RangeError) end it "sets the output string to UTF-8 encoding" do |
