Remove Net::SSH story helpers usage in FS specs
This commit is contained in:
parent
bf25b05adb
commit
b9976464a4
@ -48,16 +48,11 @@ module Producer::Core
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# FIXME: We rely a lot on mocking net-sftp heavily, while we already use a
|
describe '#file?' do
|
||||||
# part of net-ssh story helpers, which are more close to integration tests.
|
|
||||||
describe '#file?', :ssh do
|
|
||||||
let(:file_path) { 'some_file_path' }
|
let(:file_path) { 'some_file_path' }
|
||||||
let(:stat) { double 'stat' }
|
let(:stat) { double 'stat' }
|
||||||
|
|
||||||
before do
|
before { allow(sftp).to receive(:stat!) { stat } }
|
||||||
sftp_story
|
|
||||||
allow(fs.sftp).to receive(:stat!) { stat }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when path given as argument exists' do
|
context 'when path given as argument exists' do
|
||||||
context 'when path is a file' do
|
context 'when path is a file' do
|
||||||
|
@ -1,25 +1,8 @@
|
|||||||
module NetSSHStoryHelpers
|
module NetSSHStoryHelpers
|
||||||
require 'net/ssh/test'
|
require 'net/ssh/test'
|
||||||
|
|
||||||
include 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
|
def story_with_new_channel
|
||||||
story do |session|
|
story do |session|
|
||||||
ch = session.opens_channel
|
ch = session.opens_channel
|
||||||
@ -29,22 +12,6 @@ module NetSSHStoryHelpers
|
|||||||
end
|
end
|
||||||
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
|
def expect_story_completed
|
||||||
raise 'there is no story to expect' if socket.script.events.empty?
|
raise 'there is no story to expect' if socket.script.events.empty?
|
||||||
yield
|
yield
|
||||||
|
Loading…
x
Reference in New Issue
Block a user