diff options
Diffstat (limited to 'spec/ruby/core/marshal/shared')
-rw-r--r-- | spec/ruby/core/marshal/shared/load.rb | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/spec/ruby/core/marshal/shared/load.rb b/spec/ruby/core/marshal/shared/load.rb index cb041ec25c..f92d49c68c 100644 --- a/spec/ruby/core/marshal/shared/load.rb +++ b/spec/ruby/core/marshal/shared/load.rb @@ -9,7 +9,7 @@ describe :marshal_load, shared: true do it "raises an ArgumentError when the dumped data is truncated" do obj = {first: 1, second: 2, third: 3} - lambda { Marshal.send(@method, Marshal.dump(obj)[0, 5]) }.should raise_error(ArgumentError) + -> { Marshal.send(@method, Marshal.dump(obj)[0, 5]) }.should raise_error(ArgumentError) end it "raises an ArgumentError when the dumped class is missing" do @@ -17,7 +17,7 @@ describe :marshal_load, shared: true do kaboom = Marshal.dump(KaBoom.new) Object.send(:remove_const, :KaBoom) - lambda { Marshal.send(@method, kaboom) }.should raise_error(ArgumentError) + -> { Marshal.send(@method, kaboom) }.should raise_error(ArgumentError) end describe "when called with a proc" do @@ -162,20 +162,20 @@ describe :marshal_load, shared: true do marshal_data[0] = (Marshal::MAJOR_VERSION).chr marshal_data[1] = (Marshal::MINOR_VERSION + 1).chr - lambda { Marshal.send(@method, marshal_data) }.should raise_error(TypeError) + -> { Marshal.send(@method, marshal_data) }.should raise_error(TypeError) marshal_data = '\xff\xff' marshal_data[0] = (Marshal::MAJOR_VERSION - 1).chr marshal_data[1] = (Marshal::MINOR_VERSION).chr - lambda { Marshal.send(@method, marshal_data) }.should raise_error(TypeError) + -> { Marshal.send(@method, marshal_data) }.should raise_error(TypeError) end it "raises EOFError on loading an empty file" do temp_file = tmp("marshal.rubyspec.tmp.#{Process.pid}") file = File.new(temp_file, "w+") begin - lambda { Marshal.send(@method, file) }.should raise_error(EOFError) + -> { Marshal.send(@method, file) }.should raise_error(EOFError) ensure file.close rm_r temp_file @@ -567,7 +567,7 @@ describe :marshal_load, shared: true do end it "raises ArgumentError if the object from an 'o' stream is not dumpable as 'o' type user class" do - lambda do + -> do Marshal.send(@method, "\x04\bo:\tFile\001\001:\001\005@path\"\x10/etc/passwd") end.should raise_error(ArgumentError) end @@ -598,10 +598,10 @@ describe :marshal_load, shared: true do data = Marshal.dump(MarshalSpec::SwappedClass.new) MarshalSpec.set_swapped_class(Class.new(Array)) - lambda { Marshal.send(@method, data) }.should raise_error(ArgumentError) + -> { Marshal.send(@method, data) }.should raise_error(ArgumentError) MarshalSpec.set_swapped_class(Class.new) - lambda { Marshal.send(@method, data) }.should raise_error(ArgumentError) + -> { Marshal.send(@method, data) }.should raise_error(ArgumentError) end end end @@ -702,7 +702,7 @@ describe :marshal_load, shared: true do "\004\bi\004\0", "\004\bi\004\0\0", "\004\bi\004\0\0\0"].each do |invalid| - lambda { Marshal.send(@method, invalid) }.should raise_error(ArgumentError) + -> { Marshal.send(@method, invalid) }.should raise_error(ArgumentError) end end @@ -799,11 +799,11 @@ describe :marshal_load, shared: true do end it "raises ArgumentError if given the name of a non-Module" do - lambda { Marshal.send(@method, "\x04\bc\vKernel") }.should raise_error(ArgumentError) + -> { Marshal.send(@method, "\x04\bc\vKernel") }.should raise_error(ArgumentError) end it "raises ArgumentError if given a nonexistent class" do - lambda { Marshal.send(@method, "\x04\bc\vStrung") }.should raise_error(ArgumentError) + -> { Marshal.send(@method, "\x04\bc\vStrung") }.should raise_error(ArgumentError) end end @@ -813,7 +813,7 @@ describe :marshal_load, shared: true do end it "raises ArgumentError if given the name of a non-Class" do - lambda { Marshal.send(@method, "\x04\bm\vString") }.should raise_error(ArgumentError) + -> { Marshal.send(@method, "\x04\bm\vString") }.should raise_error(ArgumentError) end it "loads an old module" do @@ -852,13 +852,13 @@ describe :marshal_load, shared: true do data = "\x04\bd:\x1AUnloadableDumpableDirI\"\x06.\x06:\x06ET" - lambda { Marshal.send(@method, data) }.should raise_error(TypeError) + -> { Marshal.send(@method, data) }.should raise_error(TypeError) end it "raises ArgumentError when the local class is a regular object" do data = "\004\bd:\020UserDefined\0" - lambda { Marshal.send(@method, data) }.should raise_error(ArgumentError) + -> { Marshal.send(@method, data) }.should raise_error(ArgumentError) end end @@ -871,7 +871,7 @@ describe :marshal_load, shared: true do it "raises an ArgumentError" do message = "undefined class/module NamespaceTest::SameName" - lambda { Marshal.send(@method, @data) }.should raise_error(ArgumentError, message) + -> { Marshal.send(@method, @data) }.should raise_error(ArgumentError, message) end end @@ -880,6 +880,6 @@ describe :marshal_load, shared: true do @data = Marshal.dump(NamespaceTest::KaBoom.new) NamespaceTest.send(:remove_const, :KaBoom) - lambda { Marshal.send(@method, @data) }.should raise_error(ArgumentError, /NamespaceTest::KaBoom/) + -> { Marshal.send(@method, @data) }.should raise_error(ArgumentError, /NamespaceTest::KaBoom/) end end |