Files
metasploit-gs/spec/support/shared/contexts/msf/string_io.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

49 lines
595 B
Ruby
Raw Normal View History

2015-11-24 10:16:43 -06:00
require 'stringio'
2015-11-24 09:42:57 -06:00
RSpec.shared_context 'Msf::StringIO' do
2015-11-24 13:50:05 -06:00
#
# lets
#
2015-11-24 10:16:43 -06:00
let(:msf_io) do
2015-11-24 14:17:55 -06:00
s = StringIO.new('', 'w+b')
class << s
attr_accessor :msf_data
end
s.msf_data = ''
s.binmode
2015-11-24 14:17:55 -06:00
s
2015-11-24 09:42:57 -06:00
end
2015-11-24 12:38:19 -06:00
#
# Callbacks
#
2015-12-31 16:56:13 -06:00
before(:example) do
2015-11-24 10:16:43 -06:00
def msf_io.get_once
2015-11-24 09:42:57 -06:00
read
end
2015-11-24 10:16:43 -06:00
def msf_io.has_read_data?(_timeout)
2015-11-24 14:17:55 -06:00
!eof?
2015-11-24 09:42:57 -06:00
end
2015-11-24 10:16:43 -06:00
def msf_io.put(_data)
2015-11-24 09:42:57 -06:00
seek(0)
2015-11-24 14:17:55 -06:00
if msf_data.nil? || msf_data.empty?
length = write(_data)
2015-11-24 13:50:05 -06:00
else
2015-11-24 14:17:55 -06:00
length = write(msf_data)
2015-11-24 13:50:05 -06:00
end
2015-11-24 14:17:55 -06:00
2015-11-24 09:42:57 -06:00
seek(0)
2015-11-24 14:17:55 -06:00
length
2015-11-24 09:42:57 -06:00
end
end
end