Files
metasploit-gs/spec/support/shared/contexts/msf/string_io.rb
T
David Maloney c6656e4031 example_group and hook_scope conversions
not strictly required, these conversions keep us
up to date with latest rspec conventions and best practices
which will prevent use from having to convert them when they become
deprecated later
2015-12-31 16:56:13 -06:00

48 lines
581 B
Ruby

require 'stringio'
RSpec.shared_context 'Msf::StringIO' do
#
# lets
#
let(:msf_io) do
s = StringIO.new('', 'w+b')
class << s
attr_accessor :msf_data
end
s.msf_data = ''
s
end
#
# Callbacks
#
before(:example) do
def msf_io.get_once
read
end
def msf_io.has_read_data?(_timeout)
!eof?
end
def msf_io.put(_data)
seek(0)
if msf_data.nil? || msf_data.empty?
length = write(_data)
else
length = write(msf_data)
end
seek(0)
length
end
end
end