Skip to content

Commit

Permalink
This is why we test our assumptions :)
Browse files Browse the repository at this point in the history
  • Loading branch information
smudge committed Nov 29, 2021
1 parent fddec5e commit 7c7769c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/delayed/psych_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def encode_with(coder)
'object' => object,
'method_name' => method_name,
'args' => args,
'kwargs' => kwargs,
}
end
end
Expand Down
24 changes: 24 additions & 0 deletions spec/psych_ext_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down

0 comments on commit 7c7769c

Please sign in to comment.