Sha256: 71ee9eb955a6976f178520c5e9d2647bd671521f24a9268db41b610698947d9e

Contents?: true

Size: 1.79 KB

Versions: 15

Compression:

Stored size: 1.79 KB

Contents

require 'spec_helper'

describe PerfectQueue::Application::UndefinedDecisionError do
  it { is_expected.to be_an_instance_of(PerfectQueue::Application::UndefinedDecisionError) }
  it { is_expected.to be_a(Exception) }
end

describe PerfectQueue::Application::Decider do
  describe '#new' do
    let (:decider) { PerfectQueue::Application::Decider.new(nil) }
    it do
      expect(decider).to be_an_instance_of(PerfectQueue::Application::Decider)
    end
  end

  describe '#queue' do
    let (:queue){ double('queue') }
    let (:decider) do
      base = double('base')
      allow(base).to receive(:queue).exactly(:once).and_return(queue)
      PerfectQueue::Application::Decider.new(base)
    end
    it 'calls @base.queue' do
      expect(decider.queue).to eq(queue)
    end
  end

  describe '#task' do
    let (:task){ double('task') }
    let (:decider) do
      base = double('base')
      allow(base).to receive(:task).exactly(:once).and_return(task)
      PerfectQueue::Application::Decider.new(base)
    end
    it 'calls @base.task' do
      expect(decider.task).to eq(task)
    end
  end

  describe '#decide!' do
    let (:decider) { PerfectQueue::Application::Decider.new(nil) }
    it 'calls the specified method' do
      allow(decider).to receive(:foo).exactly(:once).with(72).and_return(42)
      expect(decider.decide!(:foo, 72)).to eq(42)
    end
    it 'raises UndefinedDecisionError on unknown method' do
      expect{ decider.decide!(:foo, 72) }.to raise_error(PerfectQueue::Application::UndefinedDecisionError)
    end
  end
end

describe PerfectQueue::Application::DefaultDecider do
  subject { PerfectQueue::Application::DefaultDecider.new(nil) }
  it { is_expected.to be_a(PerfectQueue::Application::Decider) }
  it { is_expected.to be_an_instance_of(PerfectQueue::Application::DefaultDecider) }
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
perfectqueue-0.8.54 spec/application/decider_spec.rb
perfectqueue-0.10.1 spec/application/decider_spec.rb
perfectqueue-0.8.53 spec/application/decider_spec.rb
perfectqueue-0.8.52 spec/application/decider_spec.rb
perfectqueue-0.10.0 spec/application/decider_spec.rb
perfectqueue-0.8.51 spec/application/decider_spec.rb
perfectqueue-0.8.50 spec/application/decider_spec.rb
perfectqueue-0.9.2 spec/application/decider_spec.rb
perfectqueue-0.9.1 spec/application/decider_spec.rb
perfectqueue-0.9.0 spec/application/decider_spec.rb
perfectqueue-0.8.49 spec/application/decider_spec.rb
perfectqueue-0.8.48 spec/application/decider_spec.rb
perfectqueue-0.8.47 spec/application/decider_spec.rb
perfectqueue-0.8.46 spec/application/decider_spec.rb
perfectqueue-0.8.45 spec/application/decider_spec.rb