Sha256: 638760a036d30b2fbf87bb21dcdad87857ad9a55bf85c775635c0bb7d9a32c13

Contents?: true

Size: 974 Bytes

Versions: 2

Compression:

Stored size: 974 Bytes

Contents

require 'spec_helper'

describe Berkshelf::API::CacheBuilder do
  let(:instance) { described_class.new }

  describe "#build" do
    subject(:build) { instance.build }
    let(:workers) { [ double('worker') ] }
    let(:future) { double('future', value: nil) }

    before { instance.stub(workers: workers) }

    it "sends a #build message to each worker" do
      workers.each { |worker| worker.should_receive(:future).with(:build).and_return(future) }
      build
    end
  end

  describe "#workers" do
    subject(:workers) { instance.workers }

    it "returns an array of workers" do
      expect(workers).to be_a(Array)
      workers.each do |worker|
        expect(worker).to be_a(described_class::Worker::Base)
      end
    end

    it "has one worker started by default" do
      expect(workers).to have(1).item
    end

    it "has an opscode worker started by default" do
      expect(workers.first).to be_a(described_class::Worker::Opscode)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
berkshelf-api-0.2.0 spec/unit/berkshelf/api/cache_builder_spec.rb
berkshelf-api-0.1.0 spec/unit/berkshelf/api/cache_builder_spec.rb