Describe("SSHCommand", func() { var sshCommand cli.Command BeforeEach(func() { commandFactory := command_factory.NewSSHCommandFactory(config, terminalUI, fakeExitHandler, fakeSecureShell) sshCommand = commandFactory.MakeSSHCommand() }) It("should ssh to instance 0 given an app name", func() { test_helpers.ExecuteCommandWithArgs(sshCommand, []string{"app-name"}) Expect(outputBuffer).To(test_helpers.SayLine("Connecting to app-name/0 at %s", config.Target())) Expect(fakeSecureShell.ConnectToShellCallCount()).To(Equal(1)) appName, instanceIndex, command, actualConfig := fakeSecureShell.ConnectToShellArgsForCall(0) Expect(appName).To(Equal("app-name")) Expect(instanceIndex).To(Equal(0)) Expect(command).To(BeEmpty()) Expect(actualConfig).To(Equal(config)) }) It("should ssh to instance index specified", func() { test_helpers.ExecuteCommandWithArgs(sshCommand, []string{"--instance", "2", "app-name"}) Expect(outputBuffer).To(test_helpers.SayLine("Connecting to app-name/2 at %s", config.Target())) Expect(fakeSecureShell.ConnectToShellCallCount()).To(Equal(1)) appName, instanceIndex, command, actualConfig := fakeSecureShell.ConnectToShellArgsForCall(0) Expect(appName).To(Equal("app-name")) Expect(instanceIndex).To(Equal(2))