<commit_before>require 'spec_helper'
require 'rabbitmq/http/client'

describe GovukSeedCrawler do
  let(:options) {{
      :exchange => "govuk_seed_crawler_integration",
      :topic => "#",
      :site_root => "https://www.gov.uk/",
  }}
  let(:amqp_vhost) { "/" }
  let(:rabbitmq_mgmt_client) { RabbitMQ::HTTP::Client.new("http://guest:guest@127.0.0.1:15672") }
  let(:probable_min_number_of_urls) { 1000 }

  subject { GovukSeedCrawler::Seeder::seed(options) }

  before(:each) do
    rabbitmq_mgmt_client.declare_exchange(amqp_vhost, options[:exchange], { :type => "topic" })
  end

  after(:each) do
    rabbitmq_mgmt_client.delete_exchange(amqp_vhost, options[:exchange])
  end

  it "publishes URLs it finds to an AMQP topic exchange" do
    subject

    sleep(1) # give the management API time to recognise the messages we've just published
    exchange_info = rabbitmq_mgmt_client.exchange_info(amqp_vhost, options[:exchange])
    number_of_messages_on_exchange = exchange_info["message_stats"]["publish_in"]
    expect(number_of_messages_on_exchange).to be > probable_min_number_of_urls<commit_msg>Fix AMQP argument error in integration tests<commit_after>require 'spec_helper'
require 'rabbitmq/http/client'

describe GovukSeedCrawler do
  let(:options) {{
      :amqp_exchange => "govuk_seed_crawler_integration",
      :amqp_topic => "#",
      :site_root => "https://www.gov.uk/",
  }}
  let(:amqp_vhost) { "/" }
  let(:rabbitmq_mgmt_client) { RabbitMQ::HTTP::Client.new("http://guest:guest@127.0.0.1:15672") }
  let(:probable_min_number_of_urls) { 1000 }

  subject { GovukSeedCrawler::Seeder::seed(options) }

  before(:each) do
    rabbitmq_mgmt_client.declare_exchange(amqp_vhost, options[:amqp_exchange], { :type => "topic" })
  end

  after(:each) do
    rabbitmq_mgmt_client.delete_exchange(amqp_vhost, options[:amqp_exchange])
  end

  it "publishes URLs it finds to an AMQP topic exchange" do
    subject

    sleep(1) # give the management API time to recognise the messages we've just published
    exchange_info = rabbitmq_mgmt_client.exchange_info(amqp_vhost, options[:amqp_exchange])
    number_of_messages_on_exchange = exchange_info["message_stats"]["publish_in"]
    expect(number_of_messages_on_exchange).to be > probable_min_number_of_urls
{'fraction_non_alphanumeric': 0.12323943661971831, 'fraction_numerical': 0.014084507042253521, 'mean_word_length': 5.261707988980716, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, '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': '4881877', 'n_tokens_mistral': 852, 'n_tokens_neox': 778, 'n_words': 135}