})

		Context("when given an invalid instance index", func() {
			It("prints an error", func() {
				fakeAppExaminer.AppStatusReturns(app_examiner.AppInfo{ActualRunningInstances: 1}, nil)

				test_helpers.ExecuteCommandWithArgs(sshCommand, []string{"good-app", "-i", "1"})

				Expect(outputBuffer).To(test_helpers.SayLine("Instance good-app/1 does not exist."))

				Expect(fakeSecureShell.ConnectToShellCallCount()).To(Equal(0))
				Expect(fakeExitHandler.ExitCalledWith).To(Equal([]int{exit_codes.CommandFailed}))
			})
		})

		Context("when ConnectToShell fails", func() {
			It("prints an error", func() {
				fakeAppExaminer.AppStatusReturns(app_examiner.AppInfo{ActualRunningInstances: 1}, nil)
				fakeSecureShell.ConnectToShellReturns(errors.New("connection failed"))

				test_helpers.ExecuteCommandWithArgs(sshCommand, []string{"good-app"})

				Expect(outputBuffer).To(test_helpers.SayLine("Error connecting to good-app/0: connection failed"))

				Expect(fakeSecureShell.ConnectToShellCallCount()).To(Equal(1))
				Expect(fakeExitHandler.ExitCalledWith).To(Equal([]int{exit_codes.CommandFailed}))
			})
		})
	})
})