<commit_before>require "spec_helper"

describe "a basic publisher", :integration => true do
  let(:exchange_name) { "events" }
  let(:payload) { "meow" }
  let(:route) { "bob.users.created" }

  it "publishes messages to rabbit" do
    initialize_subscriber(exchange_name, route)
    ::ActivePublisher.publish(route, payload, exchange_name)
    expect(@message).to eq([route, payload])
  end
end

def initialize_subscriber(exchange_name, route)
  connection = ::ActivePublisher::Connection.connection
  channel = connection.create_channel
  exchange = channel.topic(exchange_name)
  channel.queue("").bind(exchange, :routing_key => route).subscribe do |metadata, payload|
    @message = [metadata.routing_key, payload]
  end
end<commit_msg>add support for mri in integration test<commit_after>require "spec_helper"

describe "a basic publisher", :integration => true do
  let(:exchange_name) { "events" }
  let(:payload) { "meow" }
  let(:route) { "bob.users.created" }

  it "publishes messages to rabbit" do
    initialize_subscriber(exchange_name, route)
    ::ActivePublisher.publish(route, payload, exchange_name)
    expect(@message).to eq([route, payload])
  end
end

def initialize_subscriber(exchange_name, route)
  connection = ::ActivePublisher::Connection.connection
  channel = connection.create_channel
  exchange = channel.topic(exchange_name)

  if ::RUBY_PLATFORM == "java"
    channel.queue("").bind(exchange, :routing_key => route).subscribe do |metadata, payload|
      @message = [metadata.routing_key, payload]
    end
  else
    channel.queue("").bind(exchange, :routing_key => route).subscribe do |delivery_info, _, payload|
      @message = [delivery_info.routing_key, payload]
    end
  end
end
{'fraction_non_alphanumeric': 0.12383720930232558, 'fraction_numerical': 0.0, 'mean_word_length': 5.124555160142349, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3734935', 'n_tokens_mistral': 540, 'n_tokens_neox': 512, 'n_words': 122}