@@ -14,23 +14,37 @@ def request_response(request: nil, call: nil, method: nil, metadata: nil)
14
14
end
15
15
end
16
16
17
- let ( :interceptor ) { ExampleInterceptor . new }
17
+ def run_workflow_with_client ( client , workflow , *input , **args )
18
+ args [ :options ] = { workflow_id : SecureRandom . uuid } . merge ( args [ :options ] || { } )
19
+ run_id = client . start_workflow ( workflow , *input , **args )
18
20
19
- around ( :each ) do |example |
20
- Temporal . configure do |config |
21
- config . interceptors = [ interceptor ]
22
- end
21
+ [ args [ :options ] [ :workflow_id ] , run_id ]
22
+ end
23
23
24
- example . run
25
- ensure
26
- Temporal . configure do |config |
27
- config . interceptors = [ ]
24
+ let ( :interceptor ) { ExampleInterceptor . new }
25
+ let ( :config ) do
26
+ # We can't depend on test order here and the memoized
27
+ # Temporal.default_client will not include our interceptors. Therefore we
28
+ # build a new config and client based on the one used in the other tests.
29
+ common_config = Temporal . configuration
30
+ Temporal ::Configuration . new . tap do |config |
31
+ config . host = common_config . host
32
+ config . port = common_config . port
33
+ config . namespace = common_config . namespace
34
+ config . task_queue = common_config . task_queue
35
+ config . metrics_adapter = common_config . metrics_adapter
36
+ config . interceptors = [ interceptor ]
28
37
end
29
38
end
39
+ let ( :client ) { Temporal ::Client . new ( config ) }
30
40
31
41
it 'calls the given interceptors when performing operations' do
32
- workflow_id , run_id = run_workflow ( HelloWorldWorkflow , 'Tom' )
33
- wait_for_workflow_completion ( workflow_id , run_id )
42
+ workflow_id , run_id = run_workflow_with_client ( client , HelloWorldWorkflow , 'Tom' )
43
+ client . await_workflow_result (
44
+ HelloWorldWorkflow ,
45
+ workflow_id : workflow_id ,
46
+ run_id : run_id
47
+ )
34
48
35
49
expect ( interceptor . called_methods ) . to match_array ( [
36
50
"/temporal.api.workflowservice.v1.WorkflowService/StartWorkflowExecution" ,
0 commit comments