} if tmpdir != "" { os.RemoveAll(tmpdir) } }) Context("and the client sends a PingRequest", func() { Context("and the backend ping succeeds", func() { It("does not error", func() { Ω(apiClient.Ping()).ShouldNot(HaveOccurred()) }) }) Context("when the backend ping fails", func() { BeforeEach(func() { serverBackend.PingReturns(errors.New("oh no!")) }) It("returns an error", func() { Ω(apiClient.Ping()).Should(HaveOccurred()) }) }) Context("when the server is not up", func() { BeforeEach(func() { isRunning = false apiServer.Stop() }) It("returns an error", func() { Ω(apiClient.Ping()).Should(HaveOccurred())