diff --git a/test/functional/backends/test_netssh_scp.rb b/test/functional/backends/test_netssh_scp.rb index de02c48b..dfded0ac 100644 --- a/test/functional/backends/test_netssh_scp.rb +++ b/test/functional/backends/test_netssh_scp.rb @@ -12,6 +12,12 @@ def setup ssh.transfer_method = :scp end end + + def test_scp_implementation_is_used + Netssh.new(a_host).send(:with_transfer, nil) do |transfer| + assert_instance_of Netssh::ScpTransfer, transfer + end + end end end end diff --git a/test/functional/backends/test_netssh_sftp.rb b/test/functional/backends/test_netssh_sftp.rb index 1575fb14..73fa5af7 100644 --- a/test/functional/backends/test_netssh_sftp.rb +++ b/test/functional/backends/test_netssh_sftp.rb @@ -12,6 +12,12 @@ def setup ssh.transfer_method = :sftp end end + + def test_sftp_implementation_is_used + Netssh.new(a_host).send(:with_transfer, nil) do |transfer| + assert_instance_of Netssh::SftpTransfer, transfer + end + end end end end diff --git a/test/unit/backends/test_netssh.rb b/test/unit/backends/test_netssh.rb index 3e787e27..6d735c45 100644 --- a/test/unit/backends/test_netssh.rb +++ b/test/unit/backends/test_netssh.rb @@ -5,6 +5,12 @@ module SSHKit module Backend class TestNetssh < UnitTest + def teardown + super + # Reset config to defaults after each test + backend.instance_variable_set :@config, nil + end + def backend @backend ||= Netssh end @@ -41,6 +47,26 @@ def test_transfer_method_prohibits_invalid_values assert_match ":nope is not a valid transfer method", error.message end + def test_transfer_method_defaults_to_scp + assert_equal :scp, backend.config.transfer_method + end + + def test_host_can_override_transfer_method + backend.configure do |ssh| + ssh.transfer_method = :scp + end + + host = Host.new("fake") + host.transfer_method = :sftp + + netssh = backend.new(host) + netssh.stubs(:with_ssh).yields(nil) + + netssh.send(:with_transfer, nil) do |transfer| + assert_instance_of Netssh::SftpTransfer, transfer + end + end + def test_netssh_ext assert_includes Net::SSH::Config.default_files, "#{Dir.pwd}/.ssh/config" end