@@ -151,6 +151,74 @@ def self.reset
151
151
side_effects . reset
152
152
end
153
153
end
154
+
155
+ describe "#job_calling" do
156
+ context "with basic setup" do
157
+ class self ::TestJobCalling
158
+ include Interactify ::Async ::Jobable
159
+ job_calling method_name : :custom_method
160
+
161
+ def self . custom_method
162
+ "method called"
163
+ end
164
+ end
165
+
166
+ it "creates a job class that can call the specified method" do
167
+ job_instance = self . class ::TestJobCalling ::Job . new
168
+ expect ( job_instance . perform ) . to eq ( "method called" )
169
+ end
170
+ end
171
+
172
+ context "with custom options and class suffix" do
173
+ class self ::TestJobWithOptions
174
+ include Interactify ::Async ::Jobable
175
+ job_calling method_name : :parameter_method , opts : { queue : 'custom_queue' } , klass_suffix : 'Custom'
176
+
177
+ def self . parameter_method ( param )
178
+ param
179
+ end
180
+ end
181
+
182
+ it "applies custom options to the job class" do
183
+ expect ( self . class ::TestJobWithOptions ::JobCustom ::JOBABLE_OPTS [ :queue ] ) . to eq ( 'custom_queue' )
184
+ end
185
+
186
+ it "creates a job class with the specified suffix" do
187
+ job_instance = self . class ::TestJobWithOptions ::JobCustom . new
188
+ expect ( job_instance . perform ( 'test' ) ) . to eq ( 'test' )
189
+ end
190
+ end
191
+
192
+ context "integration with Sidekiq" do
193
+ before do
194
+ allow ( Sidekiq ::Worker ) . to receive ( :perform_async )
195
+ end
196
+
197
+ class self ::TestJobWithSidekiq
198
+ include Interactify ::Async ::Jobable
199
+
200
+ job_calling method_name : :sidekiq_method
201
+
202
+ def self . sidekiq_method
203
+ "sidekiq method"
204
+ end
205
+ end
206
+
207
+ it "enqueues job to Sidekiq" do
208
+ self . class ::TestJobWithSidekiq ::Job . perform_async
209
+
210
+ enqueued = Sidekiq ::Job . jobs . last
211
+
212
+ expect ( enqueued ) . to match (
213
+ a_hash_including (
214
+ 'retry' => true ,
215
+ 'queue' => 'default' ,
216
+ 'class' => self . class ::TestJobWithSidekiq ::Job . to_s
217
+ )
218
+ )
219
+ end
220
+ end
221
+ end
154
222
end
155
223
end
156
224
# rubocop:enable Naming/MethodParameterName
0 commit comments