aboutsummaryrefslogtreecommitdiffstats
path: root/spec/bundler/bundler/worker_spec.rb
blob: fbfe6ddab30084d4a485d0ada4ac0e552d3effde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true
require "spec_helper"
require "bundler/worker"

RSpec.describe Bundler::Worker do
  let(:size) { 5 }
  let(:name) { "Spec Worker" }
  let(:function) { proc {|object, worker_number| [object, worker_number] } }
  subject { described_class.new(size, name, function) }

  after { subject.stop }

  describe "#initialize" do
    context "when Thread.start raises ThreadError" do
      it "raises when no threads can be created" do
        allow(Thread).to receive(:start).and_raise(ThreadError, "error creating thread")

        expect { subject.enq "a" }.to raise_error(Bundler::ThreadCreationError, "Failed to create threads for the Spec Worker worker: error creating thread")
      end
    end
  end
end