<commit_before>require 'spec_helper'

describe Kohawk::Router do

  subject { Kohawk::Router.new }

  describe "public methods" do
    it { should respond_to(:exchanges) }
    it { should respond_to(:queues) }
    it { should respond_to(:subscribers) }
    it { should respond_to(:clear!) }
    it { should respond_to(:draw) }
    it { should respond_to(:eval_block) }
    it { should respond_to(:add_exchange) }
    it { should respond_to(:add_queue) }
  end

  describe "#clear!" do

    before(:each) do
      subject.draw do
        topic("test_exchange", :durable => true) do
          queue 'app:event:handler1'
          queue 'app:event:handler2'
        end
      end
    end

    it "clears the exchanges collection" do
      subject.clear!
      expect(subject.exchanges).to be_empty
    end

    it "clears the queues collection" do
      subject.clear!
      expect(subject.queues).to be_empty
    end
  end

  describe "#draw" do

    it "clears the route set" do
      expect(subject).to receive(:clear!).once
      subject.draw {}
    end

    it "yields to a given block" do
      expect { |b| subject.draw(&b) }.to yield_control
    end

    it "adds a new exchange" do
      subject.draw do
        exchange "test_exchange"
      end
      expect(subject.exchanges).to include("test_exchange")
    end

    it "adds an exchange with the give options" do
      subject.draw do
        exchange "test_exchange", :type => :topic, :durable => true
      end
      expect(subject.exchanges["test_exchange"]).to eql({:type => :topic, :durable => true})
    end

    it "adds a topic exchange" do
      subject.draw do
        topic "test_exchange", :durable => true
      end
      expect(subject.exchanges["test_exchange"]).to eql({:type => :topic, :durable => true})
    end

    it "adds a new queue" do
      subject.draw do
        topic("test_exchange", :durable => true) do
          queue 'app:event:handler'
        end
      end
      expect(subject.queues).to include('app:event:handler')
    end

    it "adds a new queue to an exchange" do
      subject.draw do
        topic("test_exchange", :durable => true) do
          queue 'app:event:handler'
        end
      end
      expect(subject.queues['app:event:handler']).to include(:exchange => {:name => 'test_exchange', :type => :topic, :durable => true})
    end

    it "uses the name param when no :as key is given" do
      subject.draw do
        queue 'app:event:handler'
      end
      expect(subject.queues).to include('app:event:handler')
    end

    it "adds a queue to the default exchange definition" do
      subject.draw do
        queue 'app:event:handler', :as => :test_event
      end
      expect(subject.queues[:test_event]).to include(:exchange => {:name => 'default', :type => :topic})
    end

    it "names the queue specified by the :as key" do
      subject.draw do
        queue 'app:event:handler', :as => :test_event
      end
      expect(subject.queues).to include(:test_event)
    end

    it "includes the name in the queue definition" do
      subject.draw do
        queue 'app:event:handler', :as => :test_event
      end
      expect(subject.queues[:test_event]).to include(:name => 'app:event:handler')
    end

    it "does not include the :as key in the queue definition" do
      subject.draw do
        queue 'app:event:handler', :as => :test_event
      end
      expect(subject.queues[:test_event]).to_not include(:as => :test_event)
    end

    it "adds the bindings to the queue definition" do
      subject.draw do
        queue 'app:event:handler', :bindings => ['private.asset.create'], :as => :test_event
      end
      expect(subject.queues[:test_event]).to include(:bindings => ['private.asset.create'])
    end

    it "adds options to the queue definition" do
      subject.draw do
        queue 'app:event:handler', :bindings => ['private.asset.create'], :options => {:durable => true, :auto_delete => true}, :as => :test_event
      end
      expect(subject.queues[:test_event]).to include(:options => {:durable => true, :auto_delete => true})
    end
<commit_msg>Updated test data.<commit_after>require 'spec_helper'

describe Kohawk::Router do

  subject { Kohawk::Router.new }

  describe "public methods" do
    it { should respond_to(:exchanges) }
    it { should respond_to(:queues) }
    it { should respond_to(:subscribers) }
    it { should respond_to(:clear!) }
    it { should respond_to(:draw) }
    it { should respond_to(:eval_block) }
    it { should respond_to(:add_exchange) }
    it { should respond_to(:add_queue) }
  end

  describe "#clear!" do

    before(:each) do
      subject.draw do
        topic("test_exchange", :durable => true) do
          queue 'app:event:handler1'
          queue 'app:event:handler2'
        end
      end
    end

    it "clears the exchanges collection" do
      subject.clear!
      expect(subject.exchanges).to be_empty
    end

    it "clears the queues collection" do
      subject.clear!
      expect(subject.queues).to be_empty
    end
  end

  describe "#draw" do

    it "clears the route set" do
      expect(subject).to receive(:clear!).once
      subject.draw {}
    end

    it "yields to a given block" do
      expect { |b| subject.draw(&b) }.to yield_control
    end

    it "adds a new exchange" do
      subject.draw do
        exchange "test_exchange"
      end
      expect(subject.exchanges).to include("test_exchange")
    end

    it "adds an exchange with the give options" do
      subject.draw do
        exchange "test_exchange", :type => :topic, :durable => true
      end
      expect(subject.exchanges["test_exchange"]).to eql({:type => :topic, :durable => true})
    end

    it "adds a topic exchange" do
      subject.draw do
        topic "test_exchange", :durable => true
      end
      expect(subject.exchanges["test_exchange"]).to eql({:type => :topic, :durable => true})
    end

    it "adds a new queue" do
      subject.draw do
        topic("test_exchange", :durable => true) do
          queue 'app:event:handler'
        end
      end
      expect(subject.queues).to include('app:event:handler')
    end

    it "adds a new queue to an exchange" do
      subject.draw do
        topic("test_exchange", :durable => true) do
          queue 'app:event:handler'
        end
      end
      expect(subject.queues['app:event:handler']).to include(:exchange => {:name => 'test_exchange', :type => :topic, :durable => true})
    end

    it "uses the name param when no :as key is given" do
      subject.draw do
        queue 'app:event:handler'
      end
      expect(subject.queues).to include('app:event:handler')
    end

    it "adds a queue to the default exchange definition" do
      subject.draw do
        queue 'app:event:handler', :as => :test_event
      end
      expect(subject.queues[:test_event]).to include(:exchange => {:name => 'default', :type => :topic})
    end

    it "names the queue specified by the :as key" do
      subject.draw do
        queue 'app:event:handler', :as => :test_event
      end
      expect(subject.queues).to include(:test_event)
    end

    it "includes the name in the queue definition" do
      subject.draw do
        queue 'app:event:handler', :as => :test_event
      end
      expect(subject.queues[:test_event]).to include(:name => 'app:event:handler')
    end

    it "does not include the :as key in the queue definition" do
      subject.draw do
        queue 'app:event:handler', :as => :test_event
      end
      expect(subject.queues[:test_event]).to_not include(:as => :test_event)
    end

    it "adds the bindings to the queue definition" do
      subject.draw do
        queue 'app:event:handler', :bindings => ['app.person.create'], :as => :test_event
      end
      expect(subject.queues[:test_event]).to include(:bindings => ['app.person.create'])
    end

    it "adds options to the queue definition" do
      subject.draw do
        queue 'app:event:handler', :bindings => ['app.person.create'], :options => {:durable => true, :auto_delete => true}, :as => :test_event
      end
      expect(subject.queues[:test_event]).to include(:options => {:durable => true, :auto_delete => true})
    end

{'fraction_non_alphanumeric': 0.12036585365853658, 'fraction_numerical': 0.0004878048780487805, 'mean_word_length': 2.680879712746858, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 71, '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': '1339008', 'n_tokens_mistral': 2535, 'n_tokens_neox': 2444, 'n_words': 728}