comparison .zfun/zsh-autosuggestions/spec/spec_helper.rb @ 467:e1ce8897030d

zsh: import df6f6f9ff41 of zsh-autosuggestions
author Augie Fackler <raf@durin42.com>
date Mon, 03 Dec 2018 22:37:29 -0500
parents
children
comparison
equal deleted inserted replaced
466:f248cf012d9a 467:e1ce8897030d
1 require 'pry'
2 require 'rspec/wait'
3 require 'terminal_session'
4
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
12 around do |example|
13 before_sourcing.call
14 session.run_command(options.join('; '))
15 session.run_command('source zsh-autosuggestions.zsh')
16 after_sourcing.call
17 session.clear_screen
18
19 example.run
20
21 session.destroy
22 end
23
24 def with_history(*commands, &block)
25 session.run_command('fc -p')
26
27 commands.each do |c|
28 c.respond_to?(:call) ? c.call : session.run_command(c)
29 end
30
31 session.clear_screen
32
33 yield block
34
35 session.send_keys('C-c')
36 session.run_command('fc -P')
37 end
38 end
39
40 RSpec.configure do |config|
41 config.expect_with :rspec do |expectations|
42 expectations.include_chain_clauses_in_custom_matcher_descriptions = true
43 end
44
45 config.mock_with :rspec do |mocks|
46 mocks.verify_partial_doubles = true
47 end
48
49 config.wait_timeout = 2
50
51 config.include_context 'terminal session'
52 end