ruby - Testing ssh connection -
an important part of project log in remote server ssh , files on it:
net::ssh.start(@host, @username, :password => @password) |ssh| ssh.exec!(rename_files_on_remote_server) end
how test it? think can have local ssh server on , check file names on (maybe in test/spec directory). or maybe point me better solution?
i think it's enough test you're sending correct commands ssh server. you're application presumably doesn't implement server - have trust server correctly working , tested.
if implement server you'd need test that, far ssh stuff goes, i'd mocking (rspec 2 syntax):
describe "ssh access" let (:ssh_connection) { mock("ssh connection") } before (:each) net::ssh.stub(:start) { ssh_connection } end "should send rename commands connection" ssh_connection.should_receive(:exec!).ordered.with("expected command") ssh_connection.should_receive(:exec!).ordered.with("next expected command") sshaccessclass.rename_files! end end
Comments
Post a Comment