From 7c7769cff95e5b1dfd83956a6d3d1c804b744722 Mon Sep 17 00:00:00 2001 From: smudge Date: Mon, 29 Nov 2021 18:08:19 -0500 Subject: [PATCH] This is why we test our assumptions :) --- lib/delayed/psych_ext.rb | 1 + spec/psych_ext_spec.rb | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/lib/delayed/psych_ext.rb b/lib/delayed/psych_ext.rb index 210ba633..f4f21105 100644 --- a/lib/delayed/psych_ext.rb +++ b/lib/delayed/psych_ext.rb @@ -6,6 +6,7 @@ def encode_with(coder) 'object' => object, 'method_name' => method_name, 'args' => args, + 'kwargs' => kwargs, } end end diff --git a/spec/psych_ext_spec.rb b/spec/psych_ext_spec.rb index b2c02f9b..8663bf64 100644 --- a/spec/psych_ext_spec.rb +++ b/spec/psych_ext_spec.rb @@ -11,6 +11,30 @@ end end + context Delayed::PerformableMethod do + it 'serializes with object, method_name, args, and kwargs' do + Delayed::PerformableMethod.new(String, :new, ['hello'], capacity: 20).tap do |pm| + serialized = YAML.dump_dj(pm) + expect(serialized).to eq <<~YAML + --- !ruby/object:Delayed::PerformableMethod + object: !ruby/class 'String' + method_name: :new + args: + - hello + kwargs: + :capacity: 20 + YAML + + deserialized = YAML.load_dj(serialized) + expect(deserialized).to be_an_instance_of(Delayed::PerformableMethod) + expect(deserialized.object).to eq String + expect(deserialized.method_name).to eq :new + expect(deserialized.args).to eq ['hello'] + expect(deserialized.kwargs).to eq(capacity: 20) + end + end + end + context ActiveRecord::Base do it 'serializes and deserializes in a version-independent way' do Story.create.tap do |story|