trabajo-afectivo/spec/support/sequencer.rb

46 lines
1 KiB
Ruby
Raw Normal View History

2022-01-01 13:38:12 +00:00
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
module SequencerUnit
def process(parameters = {}, &block)
Sequencer::Unit.process(described_class.name, parameters, &block)
end
end
module SequencerSequence
def process(parameters = {})
Sequencer.process(described_class.name,
parameters: parameters)
end
end
module SequencerCaller
def expect_sequence(sequence_name = nil)
expected_method_call = receive(:process)
if sequence_name
expected_method_call.with(sequence_name)
end
expect(Sequencer).to expected_method_call
end
def expect_no_sequence(sequence_name = nil)
expected_method_call = receive(:process)
if sequence_name
expected_method_call.with(sequence_name)
end
expect(Sequencer).not_to expected_method_call
end
end
RSpec.configure do |config|
config.include SequencerUnit, sequencer: :unit
config.include SequencerSequence, sequencer: :sequence
config.include SequencerCaller, sequencer: :caller
end