It("tries to acquire an available lock", func() { _, _, err := lockPool.AcquireLock() Ω(err).ShouldNot(HaveOccurred()) Ω(fakeLockHandler.GrabAvailableLockCallCount()).Should(Equal(1)) }) Context("when grabbing an available lock fails", func() { BeforeEach(func() { called := false fakeLockHandler.GrabAvailableLockStub = func() (string, string, error) { // succeed on second call if !called { called = true return "", "", errors.New("disaster") } else { return "", "", nil } } }) It("retries", func() { _, _, err := lockPool.AcquireLock() Ω(err).ShouldNot(HaveOccurred()) Ω(fakeLockHandler.GrabAvailableLockCallCount()).Should(Equal(2)) }) }) Context("when grabbing an available lock succeeds", func() { BeforeEach(func() {