File tree Expand file tree Collapse file tree 2 files changed +32
-5
lines changed
Expand file tree Collapse file tree 2 files changed +32
-5
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,10 @@ def serialize(resource)
1919 end
2020
2121 def serialize? ( resource )
22- resource . public_send ( "#{ context } ?" )
22+ method_name = "#{ context } ?"
23+
24+ resource . respond_to? ( method_name ) &&
25+ resource . public_send ( method_name )
2326 end
2427
2528 private
Original file line number Diff line number Diff line change 7676 end
7777
7878 context 'when serializing the user is not allowed' do
79- before do
80- allow_any_instance_of ( Userlist ::Push ::User ) . to receive ( :push? ) . and_return ( false )
79+ context 'when the context is push' do
80+ subject { described_class . new ( context : :push ) }
81+
82+ before do
83+ expect_any_instance_of ( Userlist ::Push ::User ) . to receive ( :push? ) . and_return ( false )
84+ end
85+
86+ it 'should return no payload' do
87+ expect ( payload ) . to_not be
88+ end
8189 end
8290
83- it 'should return no payload' do
84- expect ( payload ) . to_not be
91+ context 'when the context is delete' do
92+ subject { described_class . new ( context : :delete ) }
93+
94+ before do
95+ expect_any_instance_of ( Userlist ::Push ::User ) . to receive ( :delete? ) . and_return ( false )
96+ end
97+
98+ it 'should return no payload' do
99+ expect ( payload ) . to_not be
100+ end
101+ end
102+
103+ context 'when the context is unsupported' do
104+ subject { described_class . new ( context : :unsupported ) }
105+
106+ it 'should return no payload' do
107+ expect ( payload ) . to_not be
108+ end
85109 end
86110 end
87111
You can’t perform that action at this time.
0 commit comments