}) It("returns the PID of the spawned process", func() { Expect(handlerPid).To(Equal(123)) }) Context("when a null TTYSpec is passed", func() { It("asks to spawn with a tty", func() { _, spawnWithTty := spawner.SpawnArgsForCall(0) Expect(spawnWithTty).To(Equal(false)) }) }) Context("when a non-null TTYSpec is passed", func() { BeforeEach(func() { spec.TTY = &garden.TTYSpec{} }) It("asks to spawn with a tty", func() { _, spawnWithTty := spawner.SpawnArgsForCall(0) Expect(spawnWithTty).To(Equal(true)) }) }) Context("when the preparer returns an error", func() { BeforeEach(func() { preparer.PrepareCmdReturns(nil, errors.New("no cmd")) }) It("does not run the spawner", func() { Expect(spawner.SpawnCallCount()).To(Equal(0))