c6656e4031
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
48 lines
581 B
Ruby
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
|