Sha256: 69dbc1dafe27a12b08d9873e93bb10a52ca4dd83cb5a5570f50242212f7eaf7f

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

require File.join(File.dirname(__FILE__), 'support', 'spec_helper')
require 'albacore/ssh'

describe Ssh, 'when executing a command over ssh' do
	before :each do
		@sshstub = Net::SSH::Connection::Session.stub_instance(:exec! => nil)
		Net::SSH.stub_method(:start, &lambda{}).yields(@sshstub)

		@ssh = Ssh.new
		@ssh.server="server"
		@ssh.username="user"
		@ssh.password="secret"
		@ssh.commands="execute THIS!"
		
		@ssh.execute
	end
	
	it "should attempt to open a connection with the supplied connection information" do
		Net::SSH.should have_received(:start)
	end
	
	it "should execute the command" do
		@sshstub.should have_received(:exec!)
	end
end

describe Ssh, "when executing multiple commands over ssh" do
	before :each do
		@sshstub = Net::SSH::Connection::Session.stub_instance(:exec! => nil)
		Net::SSH.stub_method(:start, &lambda{}).yields(@sshstub)

		@ssh = Ssh.new
		@ssh.server="server"
		@ssh.username="user"
		@ssh.password="secret"
		
		@ssh.commands << "execute THIS!"
		@ssh.commands << "another execution"
		
		@ssh.execute		
	end
	
	it "should execute all of the specified commands" do
		@sshstub.should have_received(:exec!).twice
	end
	
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
albacore-0.0.9 spec/ssh_spec.rb
albacore-0.0.8 spec/ssh_spec.rb
albacore-0.0.7 spec/ssh_spec.rb