Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

54 linhas
1.2 KiB

  1. require 'pry'
  2. require 'rspec/wait'
  3. require 'terminal_session'
  4. require 'tempfile'
  5. RSpec.shared_context 'terminal session' do
  6. let(:term_opts) { {} }
  7. let(:session) { TerminalSession.new(term_opts) }
  8. let(:before_sourcing) { -> {} }
  9. let(:after_sourcing) { -> {} }
  10. let(:options) { [] }
  11. around do |example|
  12. before_sourcing.call
  13. session.run_command(['source zsh-autosuggestions.zsh', *options].join('; '))
  14. after_sourcing.call
  15. session.clear_screen
  16. example.run
  17. session.destroy
  18. end
  19. def with_history(*commands, &block)
  20. Tempfile.create do |f|
  21. f.write(commands.map{|c| c.gsub("\n", "\\\n")}.join("\n"))
  22. f.flush
  23. session.run_command('fc -p')
  24. session.run_command("fc -R #{f.path}")
  25. session.clear_screen
  26. yield block
  27. session.send_keys('C-c')
  28. session.run_command('fc -P')
  29. end
  30. end
  31. end
  32. RSpec.configure do |config|
  33. config.expect_with :rspec do |expectations|
  34. expectations.include_chain_clauses_in_custom_matcher_descriptions = true
  35. end
  36. config.mock_with :rspec do |mocks|
  37. mocks.verify_partial_doubles = true
  38. end
  39. config.wait_timeout = 2
  40. config.include_context 'terminal session'
  41. end