From b9976464a44e114f523180518d010ab7b893990f Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Wed, 5 Mar 2014 06:47:55 +0000 Subject: [PATCH] Remove Net::SSH story helpers usage in FS specs --- spec/producer/core/remote/fs_spec.rb | 9 ++----- spec/support/net_ssh_story_helpers.rb | 35 +-------------------------- 2 files changed, 3 insertions(+), 41 deletions(-) diff --git a/spec/producer/core/remote/fs_spec.rb b/spec/producer/core/remote/fs_spec.rb index 2642a7c..39278d3 100644 --- a/spec/producer/core/remote/fs_spec.rb +++ b/spec/producer/core/remote/fs_spec.rb @@ -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 diff --git a/spec/support/net_ssh_story_helpers.rb b/spec/support/net_ssh_story_helpers.rb index a386503..d86a039 100644 --- a/spec/support/net_ssh_story_helpers.rb +++ b/spec/support/net_ssh_story_helpers.rb @@ -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