Sha256: 945c8dfa478b167224f18d58234d2d4a84ceabbf267679601b7c153f3400d2b6

Contents?: true

Size: 921 Bytes

Versions: 13

Compression:

Stored size: 921 Bytes

Contents

module IntegrationSupport
  def setup_publisher
    publisher = DispatchRider::Publisher.new
    publisher.register_notification_service :file_system
    publisher.register_destination :dst, :file_system, :dst_channel, path: 'tmp/test_queue'
    publisher
  end

  def purge_test_queue
    Dir['tmp/test_queue/*'].each { |fn| File.unlink(fn) }
  end

  def setup_subscriber
    subscriber = DispatchRider.config.subscriber.new
    subscriber.register_queue(:file_system, path: 'tmp/test_queue')
    subscriber.register_handler(:sample_handler)
    subscriber.register_handler(:crashing_handler)
    subscriber
  end

  def work_off_jobs(subscriber, fail_on_error: true)
    subscriber.setup_demultiplexer(:file_system, ->(_message, error) { raise error if fail_on_error })

    class << subscriber.demultiplexer
      def keep_going?
        !queue.empty?
      end
    end

    subscriber.demultiplexer.start
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
dispatch-rider-1.9.0 spec/support/integration_support.rb
dispatch-rider-1.8.6 spec/support/integration_support.rb
dispatch-rider-1.8.5 spec/support/integration_support.rb
dispatch-rider-1.8.4 spec/support/integration_support.rb
dispatch-rider-1.8.3 spec/support/integration_support.rb
dispatch-rider-1.8.2 spec/support/integration_support.rb
dispatch-rider-1.8.1 spec/support/integration_support.rb
dispatch-rider-1.8.0 spec/support/integration_support.rb
dispatch-rider-1.7.2 spec/support/integration_support.rb
dispatch-rider-1.7.1 spec/support/integration_support.rb
dispatch-rider-1.7.0 spec/support/integration_support.rb
dispatch-rider-1.6.2 spec/support/integration_support.rb
dispatch-rider-1.6.1 spec/support/integration_support.rb