sequencer.rb 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module SequencerUnit
  3. def process(parameters = {}, &)
  4. Sequencer::Unit.process(described_class.name, parameters, &)
  5. end
  6. end
  7. module SequencerSequence
  8. def process(parameters = {})
  9. Sequencer.process(described_class.name,
  10. parameters: parameters)
  11. end
  12. end
  13. module SequencerCaller
  14. def expect_sequence(sequence_name = nil)
  15. expected_method_call = receive(:process)
  16. if sequence_name
  17. expected_method_call.with(sequence_name)
  18. end
  19. expect(Sequencer).to expected_method_call
  20. end
  21. def expect_no_sequence(sequence_name = nil)
  22. expected_method_call = receive(:process)
  23. if sequence_name
  24. expected_method_call.with(sequence_name)
  25. end
  26. expect(Sequencer).not_to expected_method_call
  27. end
  28. end
  29. RSpec.configure do |config|
  30. config.include SequencerUnit, sequencer: :unit
  31. config.include SequencerSequence, sequencer: :sequence
  32. config.include SequencerCaller, sequencer: :caller
  33. end