Skip to content

Commit 7c7769c

Browse files
committed
This is why we test our assumptions :)
1 parent fddec5e commit 7c7769c

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

lib/delayed/psych_ext.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ def encode_with(coder)
66
'object' => object,
77
'method_name' => method_name,
88
'args' => args,
9+
'kwargs' => kwargs,
910
}
1011
end
1112
end

spec/psych_ext_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,30 @@
1111
end
1212
end
1313

14+
context Delayed::PerformableMethod do
15+
it 'serializes with object, method_name, args, and kwargs' do
16+
Delayed::PerformableMethod.new(String, :new, ['hello'], capacity: 20).tap do |pm|
17+
serialized = YAML.dump_dj(pm)
18+
expect(serialized).to eq <<~YAML
19+
--- !ruby/object:Delayed::PerformableMethod
20+
object: !ruby/class 'String'
21+
method_name: :new
22+
args:
23+
- hello
24+
kwargs:
25+
:capacity: 20
26+
YAML
27+
28+
deserialized = YAML.load_dj(serialized)
29+
expect(deserialized).to be_an_instance_of(Delayed::PerformableMethod)
30+
expect(deserialized.object).to eq String
31+
expect(deserialized.method_name).to eq :new
32+
expect(deserialized.args).to eq ['hello']
33+
expect(deserialized.kwargs).to eq(capacity: 20)
34+
end
35+
end
36+
end
37+
1438
context ActiveRecord::Base do
1539
it 'serializes and deserializes in a version-independent way' do
1640
Story.create.tap do |story|

0 commit comments

Comments
 (0)