diff options
Diffstat (limited to 'activesupport/test/core_ext/marshal_test.rb')
-rw-r--r-- | activesupport/test/core_ext/marshal_test.rb | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/activesupport/test/core_ext/marshal_test.rb b/activesupport/test/core_ext/marshal_test.rb index 380f64c6fd..7ac051b4b1 100644 --- a/activesupport/test/core_ext/marshal_test.rb +++ b/activesupport/test/core_ext/marshal_test.rb @@ -1,6 +1,8 @@ -require 'abstract_unit' -require 'active_support/core_ext/marshal' -require 'dependencies_test_helpers' +# frozen_string_literal: true + +require "abstract_unit" +require "active_support/core_ext/marshal" +require "dependencies_test_helpers" class MarshalTest < ActiveSupport::TestCase include ActiveSupport::Testing::Isolation @@ -12,13 +14,26 @@ class MarshalTest < ActiveSupport::TestCase end test "that Marshal#load still works" do - sanity_data = ["test", [1, 2, 3], {a: [1, 2, 3]}, ActiveSupport::TestCase] + sanity_data = ["test", [1, 2, 3], { a: [1, 2, 3] }, ActiveSupport::TestCase] sanity_data.each do |obj| dumped = Marshal.dump(obj) assert_equal Marshal.method(:load).super_method.call(dumped), Marshal.load(dumped) end end + test "that Marshal#load still works when passed a proc" do + example_string = "test" + + example_proc = Proc.new do |o| + if o.is_a?(String) + o.capitalize! + end + end + + dumped = Marshal.dump(example_string) + assert_equal Marshal.load(dumped, example_proc), "Test" + end + test "that a missing class is autoloaded from string" do dumped = nil with_autoloading_fixtures do |