|
|
@ -1,6 +1,7 @@
|
|
|
|
require 'pry'
|
|
|
|
require 'pry'
|
|
|
|
require 'rspec/wait'
|
|
|
|
require 'rspec/wait'
|
|
|
|
require 'terminal_session'
|
|
|
|
require 'terminal_session'
|
|
|
|
|
|
|
|
require 'tempfile'
|
|
|
|
|
|
|
|
|
|
|
|
RSpec.shared_context 'terminal session' do
|
|
|
|
RSpec.shared_context 'terminal session' do
|
|
|
|
let(:term_opts) { {} }
|
|
|
|
let(:term_opts) { {} }
|
|
|
@ -21,18 +22,20 @@ RSpec.shared_context 'terminal session' do
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def with_history(*commands, &block)
|
|
|
|
def with_history(*commands, &block)
|
|
|
|
session.run_command('fc -p')
|
|
|
|
Tempfile.create do |f|
|
|
|
|
|
|
|
|
f.write(commands.map{|c| c.gsub("\n", "\\\n")}.join("\n"))
|
|
|
|
|
|
|
|
f.flush
|
|
|
|
|
|
|
|
|
|
|
|
commands.each do |c|
|
|
|
|
session.run_command('fc -p')
|
|
|
|
c.respond_to?(:call) ? c.call : session.run_command(c)
|
|
|
|
session.run_command("fc -R #{f.path}")
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
session.clear_screen
|
|
|
|
session.clear_screen
|
|
|
|
|
|
|
|
|
|
|
|
yield block
|
|
|
|
yield block
|
|
|
|
|
|
|
|
|
|
|
|
session.send_keys('C-c')
|
|
|
|
session.send_keys('C-c')
|
|
|
|
session.run_command('fc -P')
|
|
|
|
session.run_command('fc -P')
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|