Module: Ghaki::NetSSH::SpecHelper

Includes:
Logger::SpecHelper
Defined in:
lib/ghaki/net_ssh/spec_helper.rb

Instance Method Summary collapse

Instance Method Details

#clear_safe_gak_net_sshObject



37
38
39
# File 'lib/ghaki/net_ssh/spec_helper.rb', line 37

def clear_safe_gak_net_ssh
  @ssh_gak = nil
end

#reset_safe_gak_net_ssh(opts = {}) ⇒ Object



59
60
61
62
# File 'lib/ghaki/net_ssh/spec_helper.rb', line 59

def reset_safe_gak_net_ssh opts={}
  clear_safe_gak_net_ssh
  setup_safe_gak_net_ssh opts
end

#setup_safe_gak_net_ssh(opts = {}) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ghaki/net_ssh/spec_helper.rb', line 41

def setup_safe_gak_net_ssh opts={}
  return unless @ssh_gak.nil?
  setup_safe_logger
  stub_gak_net_ssh
  opts[:hostname] ||= 'host'
  opts[:username] ||= 'user'
  opts[:password] ||= 'secret'
  opts[:logger] ||= @logger
  @ssh_gak = Ghaki::NetSSH::Shell.start(opts)
  @ssh_gak.stubs({
    :sftp   => @ftp_gak,
    :telnet => @tel_gak,
  })
  Ghaki::NetSSH::Shell.stubs({
    :new => @ssh_gak,
  })
end

#stub_gak_net_sshObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ghaki/net_ssh/spec_helper.rb', line 25

def stub_gak_net_ssh
  stub_raw_net_ssh
  @ftp_gak = stub_everything('Ghaki::NetSSH::FTP')
  Ghaki::NetSSH::FTP.stubs({
    :new => @ftp_gak,
  })
  @tel_gak = stub_everything('Ghaki::NetSSH::Telnet')
  Ghaki::NetSSH::Telnet.stubs({
    :new => @tel_gak,
  })
end

#stub_raw_net_sshObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ghaki/net_ssh/spec_helper.rb', line 10

def stub_raw_net_ssh
  @tel_raw = stub_everything('Net::Telnet')
  ::Net::SSH::Telnet.stubs({
    :new => @tel_raw,
  })
  @ssh_raw = stub_everything('Net::SSH')
  ::Net::SSH.stubs({
    :start => @ssh_raw,
  })
  @ftp_raw = stub_everything('Net::SFTP')
  @ssh_raw.stubs({
    :sftp => @ftp_raw,
  })
end