From e52556b5f52bd4d57307a9102b54bbb56e5bb888 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 9 Apr 2014 16:00:17 -0700 Subject: [PATCH] tests passing --- .../commands/ssh_config/command_test.rb | 55 ++++++++++++++----- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/test/unit/plugins/commands/ssh_config/command_test.rb b/test/unit/plugins/commands/ssh_config/command_test.rb index 7e8b9be6e..f80c5b225 100644 --- a/test/unit/plugins/commands/ssh_config/command_test.rb +++ b/test/unit/plugins/commands/ssh_config/command_test.rb @@ -36,7 +36,14 @@ describe VagrantPlugins::CommandSSHConfig::Command do describe "execute" do it "prints out the ssh config for the given machine" do - expect(subject).to receive(:safe_puts).with(<<-SSHCONFIG) + output = "" + allow(subject).to receive(:safe_puts) do |data| + output += data if data + end + + subject.execute + + expect(output).to eq(<<-SSHCONFIG) Host #{machine.name} HostName testhost.vagrant.dev User testuser @@ -47,40 +54,58 @@ Host #{machine.name} IdentitiesOnly yes LogLevel FATAL SSHCONFIG - subject.execute end it "turns on agent forwarding when it is configured" do allow(machine).to receive(:ssh_info) { ssh_info.merge(:forward_agent => true) } - expect(subject).to receive(:safe_puts).with { |ssh_config| - expect(ssh_config).to include("ForwardAgent yes") - } + + output = "" + allow(subject).to receive(:safe_puts) do |data| + output += data if data + end + subject.execute + + expect(output).to include("ForwardAgent yes") end it "turns on x11 forwarding when it is configured" do allow(machine).to receive(:ssh_info) { ssh_info.merge(:forward_x11 => true) } - expect(subject).to receive(:safe_puts).with { |ssh_config| - expect(ssh_config).to include("ForwardX11 yes") - } + + output = "" + allow(subject).to receive(:safe_puts) do |data| + output += data if data + end + subject.execute + + expect(output).to include("ForwardX11 yes") end it "handles multiple private key paths" do allow(machine).to receive(:ssh_info) { ssh_info.merge(:private_key_path => ["foo", "bar"]) } - expect(subject).to receive(:safe_puts).with { |ssh_config| - expect(ssh_config).to include("IdentityFile foo") - expect(ssh_config).to include("IdentityFile bar") - } + + output = "" + allow(subject).to receive(:safe_puts) do |data| + output += data if data + end + subject.execute + + expect(output).to include("IdentityFile foo") + expect(output).to include("IdentityFile bar") end it "puts quotes around an identityfile path if it has a space" do allow(machine).to receive(:ssh_info) { ssh_info.merge(:private_key_path => ["with a space"]) } - expect(subject).to receive(:safe_puts).with { |ssh_config| - expect(ssh_config).to include('IdentityFile "with a space"') - } + output = "" + allow(subject).to receive(:safe_puts) do |data| + output += data if data + end + subject.execute + + expect(output).to include('IdentityFile "with a space"') end end end