Sha256: 401d2d0a1f6f74a5b8eafff1fa611618e5728b826ade3ad37ab9ff364e50a62c

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe MailRoom::Coordinator do
  describe '#initialize' do
    it 'builds a watcher for each mailbox' do
      MailRoom::MailboxWatcher.stubs(:new).returns('watcher1', 'watcher2')

      coordinator = MailRoom::Coordinator.new(['mailbox1', 'mailbox2'])

      coordinator.watchers.should eq(['watcher1', 'watcher2'])

      MailRoom::MailboxWatcher.should have_received(:new).with('mailbox1')
      MailRoom::MailboxWatcher.should have_received(:new).with('mailbox2')
    end

    it 'makes no watchers when mailboxes is empty' do
      coordinator = MailRoom::Coordinator.new([])
      coordinator.watchers.should eq([])
    end
  end

  describe '#run' do
    it 'runs each watcher' do
      watcher = stub(:run)
      MailRoom::MailboxWatcher.stubs(:new).returns(watcher)
      coordinator = MailRoom::Coordinator.new(['mailbox1'])
      coordinator.stubs(:running?).returns(false)
      coordinator.run
      watcher.should have_received(:run)
    end
  end

  describe '#quit' do
    it 'quits each watcher' do
      watcher = stub(:quit)
      MailRoom::MailboxWatcher.stubs(:new).returns(watcher)
      coordinator = MailRoom::Coordinator.new(['mailbox1'])
      coordinator.stubs(:running?).returns(true)
      coordinator.quit
      watcher.should have_received(:quit)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mail_room-0.1.0 spec/lib/coordinator_spec.rb
mail_room-0.0.3 spec/lib/coordinator_spec.rb
mail_room-0.0.2 spec/lib/coordinator_spec.rb