Sha256: 5b9a2ba470f0f87aa735d4662627c85bcb041de814205313df8eabe448a3386c

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'message_driver'

class TestRunner
  include MessageDriver::MessagePublisher
  include RSpec::Matchers

  attr_accessor :raised_error

  def config_broker(src)
    instance_eval(src)
  end

  def run_test_code(src)
    begin
      instance_eval(src)
    rescue Exception => e
      @raised_error = e
    end
  end

  def fetch_messages(destination)
    case destination
    when String, Symbol
      fetch_messages(MessageDriver::Broker.find_destination(destination))
    when MessageDriver::Destination::Base
      result = []
      begin
        msg = destination.pop_message
        result << msg unless msg.nil?
      end until msg.nil?
      result
    else
      raise "didn't understand destination #{destination}"
    end
  end

  def publish_table_to_destination(destination, table)
    table.hashes.each do |msg|
      destination.publish(msg[:body], msg[:headers]||{}, msg[:properties]||{})
    end
  end
end

module KnowsMyTestRunner
  def test_runner
    @test_runner ||= TestRunner.new
  end
end

World(KnowsMyTestRunner)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
message-driver-0.1.0 features/support/test_runner.rb