adomokos / light-service

Series of Actions with an emphasis on simplicity.
MIT License
837 stars 67 forks source link

Skipping the remaining actions in a `reduce_until` leads to an infinite loop #143

Closed jeremy-hanna closed 6 years ago

jeremy-hanna commented 6 years ago

Summary

Including a ctx.skip_remaining! in a reduce_until step causes an infinite loop of execution.

Recreation

class OrchestratorTestSkipState
  extend LightService::Orchestrator

  def self.run_inside_skip
    with(:number => 1).reduce([
                                reduce_until(->(ctx) { ctx[:number] == 3 }, [
                                             TestDoubles::SkipAllAction,
                                             TestDoubles::AddOneAction ])
                              ])
  end
end

it 'skips all the rest of the actions' do
  result = OrchestratorTestSkipState.run_inside_skip

  expect(result).to be_success
  expect(result[:number]).to eq(1)
end