class RabbitMQSpec::Setup

Does the AMPQ Broker setup by reading all mqspecs files, evaluating them and connecting to the broker using the provided url in order to create all exchanges, queues and bindings @example

RabbitMQSpec::Setup.run(['/my/path/folde1', 'my/direct_mqspec/file.rb'], 'amqp://guest:guest@localhost:5672')

Public Class Methods

run(files_paths:, url:) click to toggle source
# File lib/rabbitmq-spec/setup.rb, line 14
def run(files_paths:, url:)
  with_client(url) do |client|
    RabbitMQSpec::Setup::Runner.new(files_paths, client).run
  end
end
with_client(ampq_broker_url) { |channel| ... } click to toggle source

@private

# File lib/rabbitmq-spec/setup.rb, line 21
def with_client(ampq_broker_url)
  client = Bunny.new(ampq_broker_url, automatically_recover: false)
  channel = nil
  begin
    client.start
    channel = client.create_channel
    yield(channel)
  rescue Exception => ex
    raise ex
  ensure
    channel && channel.close
    client && client.close
  end
end