diff --git a/spec/core/marshal/dump_spec.rb b/spec/core/marshal/dump_spec.rb index 25b08ae94..5657a227e 100644 --- a/spec/core/marshal/dump_spec.rb +++ b/spec/core/marshal/dump_spec.rb @@ -321,21 +321,15 @@ def _dump(level) describe "with a String" do it "dumps a blank String" do - NATFIXME 'dumps a blank String', exception: SpecFailedException do - Marshal.dump("".dup.force_encoding("binary")).should == "\004\b\"\000" - end + Marshal.dump("".dup.force_encoding("binary")).should == "\004\b\"\000" end it "dumps a short String" do - NATFIXME 'dumps a short String', exception: SpecFailedException do - Marshal.dump("short".dup.force_encoding("binary")).should == "\004\b\"\012short" - end + Marshal.dump("short".dup.force_encoding("binary")).should == "\004\b\"\012short" end it "dumps a long String" do - NATFIXME 'dumps a long String', exception: SpecFailedException do - Marshal.dump(("big" * 100).force_encoding("binary")).should == "\004\b\"\002,\001#{"big" * 100}" - end + Marshal.dump(("big" * 100).force_encoding("binary")).should == "\004\b\"\002,\001#{"big" * 100}" end it "dumps a String extended with a Module" do diff --git a/spec/core/marshal/shared/load.rb b/spec/core/marshal/shared/load.rb index 253935947..379332edd 100644 --- a/spec/core/marshal/shared/load.rb +++ b/spec/core/marshal/shared/load.rb @@ -484,9 +484,7 @@ arr = ArraySubPush.new arr[0] = '1' arr_dump = Marshal.dump(arr) - NATFIXME 'loads subclasses of Array with overridden << and push correctly', exception: ArgumentError, message: 'marshal data too short' do - Marshal.send(@method, arr_dump).should == arr - end + Marshal.send(@method, arr_dump).should == arr end it "raises a TypeError with bad Marshal version" do @@ -612,7 +610,7 @@ h = { key: s } h.instance_variable_set :@hash_ivar, 'hash ivar' - NATFIXME 'preserves hash ivars when hash contains a string having ivar', exception: ArgumentError, message: 'marshal data too short' do + NATFIXME 'preserves hash ivars when hash contains a string having ivar', exception: SpecFailedException do unmarshalled = Marshal.send(@method, Marshal.dump(h)) unmarshalled.instance_variable_get(:@hash_ivar).should == 'hash ivar' unmarshalled[:key].instance_variable_get(:@string_ivar).should == 'string ivar' @@ -746,9 +744,7 @@ it "loads a string through StringIO stream" do require 'stringio' obj = "This is a string which should be unmarshalled through StringIO stream!" - NATFIXME 'loads a string through StringIO stream', exception: ArgumentError, message: 'marshal data too short' do - Marshal.send(@method, StringIO.new(Marshal.dump(obj))).should == obj - end + Marshal.send(@method, StringIO.new(Marshal.dump(obj))).should == obj end it "sets binmode if it is loading through StringIO stream" do @@ -810,13 +806,11 @@ def io.binmode; raise "binmode"; end end it "raises ArgumentError when end of byte sequence reached before string characters end" do - NATFIXME 'raises ArgumentError when end of byte sequence reached before string characters end', exception: SpecFailedException do - Marshal.dump("hello").should == "\x04\b\"\nhello" + Marshal.dump("hello").should == "\x04\b\"\nhello" - -> { - Marshal.send(@method, "\x04\b\"\nhel") - }.should raise_error(ArgumentError, "marshal data too short") - end + -> { + Marshal.send(@method, "\x04\b\"\nhel") + }.should raise_error(ArgumentError, "marshal data too short") end end diff --git a/src/marshal.rb b/src/marshal.rb index cebffccec..5b01806c9 100644 --- a/src/marshal.rb +++ b/src/marshal.rb @@ -140,10 +140,10 @@ def write_integer(value) end def write_string(value) - write_char('I') + write_char('I') if value.encoding != Encoding::ASCII_8BIT write_char('"') write_string_bytes(value) - write_encoding_bytes(value) + write_encoding_bytes(value) if value.encoding != Encoding::ASCII_8BIT end def write_symbol(value)