Module: RubyReactor::RSpec::StepExecutorPatch
- Defined in:
- lib/ruby_reactor/rspec/step_executor_patch.rb
Overview
Patch StepExecutor to handle inline async execution during tests. This ensures that when a worker runs inline (e.g. Sidekiq::Testing.inline!), the calling executor can pick up the state change immediately and continue, preventing stalled execution in nested async scenarios.
Instance Method Summary collapse
Instance Method Details
#execute_step(step_config) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ruby_reactor/rspec/step_executor_patch.rb', line 12 def execute_step(step_config) # 1. Call original implementation result = super # 2. Add test-specific logic for inline async execution # Only interfere if we got an AsyncResult and we are in a testing environment that supports inline execution if should_check_inline_completion?(result) # Check if it finished or paused inline (e.g. Sidekiq::Testing.inline!) refresh_context_from_storage # If the step itself now has a result, it means it ran inline if @context.has_result?(step_config.name) # If the step failed, we should return failure return reconstruct_failure(@context.failure_reason) if @context.failed? return nil # Continue to next step end # If the overall reactor finished or paused for other reasons (e.g. error in worker) if @context.finished? || @context.status.to_s == "paused" return reconstruct_failure(@context.failure_reason) if @context.failed? if @context.status.to_s == "paused" return RubyReactor::InterruptResult.new( execution_id: @context.context_id, intermediate_results: @context.intermediate_results ) end return nil # Finished successfully end end # Return original result if no intervention needed result end |