Sha256: 008679a006084b0e52beab6e21b76081b46c9c4d91ab21a106a06340698ca74c

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'
require 'drama_queen'


describe DramaQueen do
  subject do
    described_class
  end

  let(:exchange) { double 'DramaQueen::Exchange' }

  describe '.exchanges' do
    it 'is created as an empty Array' do
      expect(subject.exchanges).to be_an_instance_of Array
    end
  end

  describe '.exchange_for' do
    before do
      allow(subject).to receive(:exchanges) { [exchange] }
    end

    context 'does not route' do
      before { allow(exchange).to receive(:routing_key) { 'another key' } }
      specify { expect(subject.exchange_for 'test_key').to eq nil }
    end

    context 'does route' do
      before { allow(exchange).to receive(:routing_key) { 'test_key' } }
      specify { expect(subject.exchange_for 'test_key').to eq exchange }
    end
  end

  describe '.routes_to?' do
    before do
      allow(subject).to receive(:exchanges) { [exchange] }
    end

    context 'does not route' do
      before do
        allow(subject).to receive(:exchange_for).
          with('test_key') { false }
      end

      specify { expect(subject.routes_to? 'test_key').to eq false }
    end

    context 'does route' do
      before do
        allow(subject).to receive(:exchange_for).
          with('test_key') { true }
      end

      specify { expect(subject.routes_to? 'test_key').to eq true }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
drama_queen-0.1.1 spec/unit/drama_queen_spec.rb
drama_queen-0.1.0 spec/unit/drama_queen_spec.rb