Skip to content

Commit 40bb32d

Browse files
committed
Simplify spec: Extract duplicate double(:server) setup
1 parent ce10332 commit 40bb32d

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

spec/unit/lib/cloud_controller/runner_spec.rb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,18 @@ module VCAP::CloudController
2626
end
2727

2828
describe '#run!' do
29-
it 'creates a pidfile' do
30-
expect(VCAP::PidFile).to receive(:new).with('/tmp/cloud_controller.pid')
29+
let(:server) { double(:server, start!: nil) }
3130

32-
server = double(:server)
33-
allow(server).to receive(:start!)
34-
expect(VCAP::CloudController::PumaRunner).to receive(:new).and_return(server)
31+
before do
32+
allow(VCAP::CloudController::PumaRunner).to receive(:new).and_return(server)
33+
end
3534

35+
it 'creates a pidfile' do
36+
expect(VCAP::PidFile).to receive(:new).with('/tmp/cloud_controller.pid')
3637
subject.run!
3738
end
3839

3940
it 'starts the web server' do
40-
server = double(:server)
41-
allow(server).to receive(:start!)
42-
expect(VCAP::CloudController::PumaRunner).to receive(:new).and_return(server)
43-
4441
subject.run!
4542
expect(server).to have_received(:start!).once
4643
end

0 commit comments

Comments
 (0)