Remove Net::SSH story helpers usage in FS specs

This commit is contained in:
Thibault Jouan 2014-03-05 06:47:55 +00:00
parent bf25b05adb
commit b9976464a4
2 changed files with 3 additions and 41 deletions

View File

@ -48,16 +48,11 @@ module Producer::Core
end
end
# FIXME: We rely a lot on mocking net-sftp heavily, while we already use a
# part of net-ssh story helpers, which are more close to integration tests.
describe '#file?', :ssh do
describe '#file?' do
let(:file_path) { 'some_file_path' }
let(:stat) { double 'stat' }
before do
sftp_story
allow(fs.sftp).to receive(:stat!) { stat }
end
before { allow(sftp).to receive(:stat!) { stat } }
context 'when path given as argument exists' do
context 'when path is a file' do

View File

@ -1,25 +1,8 @@
module NetSSHStoryHelpers
require 'net/ssh/test'
include Net::SSH::Test
# FIXME: must be moved elsewhere or implemented another way/form.
class ::Net::SSH::Test::Channel
def gets_packet(type, *args)
gets_data(sftp_packet(type, *args))
end
def sends_packet(type, *args)
sends_data(sftp_packet(type, *args))
end
private
def sftp_packet(type, *args)
data = Net::SSH::Buffer.from(*args)
Net::SSH::Buffer.from(:long, data.length + 1, :byte, type, :raw, data).to_s
end
end
def story_with_new_channel
story do |session|
ch = session.opens_channel
@ -29,22 +12,6 @@ module NetSSHStoryHelpers
end
end
def sftp_story
story do |session|
ch = session.opens_channel
ch.sends_subsystem 'sftp'
ch.sends_packet(
Net::SFTP::Constants::PacketTypes::FXP_INIT, :long,
Net::SFTP::Session::HIGHEST_PROTOCOL_VERSION_SUPPORTED
)
ch.gets_packet(
Net::SFTP::Constants::PacketTypes::FXP_VERSION, :long,
Net::SFTP::Session::HIGHEST_PROTOCOL_VERSION_SUPPORTED
)
yield ch if block_given?
end
end
def expect_story_completed
raise 'there is no story to expect' if socket.script.events.empty?
yield