<commit_before>require 'spec_helper'

describe Travis::Amqp::Publisher do
  let(:connection) {Travis::Amqp.connection}
  before do
    Travis::Amqp.config = {
      :host => 'localhost'
    }
    connection
  end
  let(:publisher) {Travis::Amqp::Publisher.new('reporting')}
  let(:queue) {
    queue = connection.queue('reporting')
    exchange = connection.exchange('reporting.jobs.1', :durable => true, :type => :topic, :auto_delete => false)
    queue.bind(exchange, :key => 'reporting')
    queue
  }

  let(:message) {
    queue.pop
  }

  it "should encode the data as json" do
    publisher.publish({})
    message.should_not == nil
    message[:payload].should == "{}"
  end

  it "should default to a direct type" do
    publisher.type.should == "direct"
  end

end<commit_msg>Exclude JRuby.<commit_after>require 'spec_helper'

if RUBY_PLATFORM != 'java'
  describe Travis::Amqp::Publisher do
    let(:connection) {Travis::Amqp.connection}
    before do
      Travis::Amqp.config = {
        :host => 'localhost'
      }
      connection
    end
    let(:publisher) {Travis::Amqp::Publisher.new('reporting')}
    let(:queue) {
      queue = connection.queue('reporting')
      exchange = connection.exchange('reporting.jobs.1', :durable => true, :type => :topic, :auto_delete => false)
      queue.bind(exchange, :key => 'reporting')
      queue
    }

    let(:message) {
      queue.pop
    }

    it "should encode the data as json" do
      publisher.publish({})
      message.should_not == nil
      message[:payload].should == "{}"
    end

    it "should default to a direct type" do
      publisher.type.should == "direct"
    end

  end
end
{'fraction_non_alphanumeric': 0.14414957780458384, 'fraction_numerical': 0.0012062726176115801, 'mean_word_length': 3.086206896551724, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '3427366', 'n_tokens_mistral': 550, 'n_tokens_neox': 522, 'n_words': 120}