@@ -389,15 +389,10 @@ def do_registration_test(
389389 metafield_namespaces : nil
390390 )
391391 # Given
392- ShopifyAPI ::Webhooks ::Registry . clear
393-
394- stub_request ( :post , @url )
395- . with ( body : JSON . dump ( { query : queries [ delivery_method ] [ :check_query ] , variables : nil } ) )
396- . to_return ( { status : 200 , body : JSON . dump ( expected_check_response ) } )
397-
398- stub_request ( :post , @url )
399- . with ( body : JSON . dump ( { query : expected_update_webhook_query , variables : nil } ) )
400- . to_return ( { status : 200 , body : JSON . dump ( expected_update_webhook_response ) } )
392+ setup_queries_and_responses (
393+ [ queries [ delivery_method ] [ :check_query ] , expected_update_webhook_query ] ,
394+ [ expected_check_response , expected_update_webhook_response ] ,
395+ )
401396
402397 # When
403398 update_registration_response = add_and_register_webhook (
@@ -430,6 +425,15 @@ def add_and_register_webhook(protocol, address, fields: nil, metafield_namespace
430425
431426 update_registration_response
432427 end
428+
429+ def setup_queries_and_responses ( queries , responses )
430+ ShopifyAPI ::Webhooks ::Registry . clear
431+ queries . zip ( responses ) . each do |query , response |
432+ stub_request ( :post , @url )
433+ . with ( body : JSON . dump ( { query : query , variables : nil } ) )
434+ . to_return ( { status : 200 , body : JSON . dump ( response ) } )
435+ end
436+ end
433437 end
434438 end
435439end
0 commit comments