Repository: junegunn/fzf
File: test/test_go.rb (Ruby)

Code before:

  def test_clear_query
    tmux.send_keys %(: | #{FZF} --query foo --bind space:clear-query), :Enter
    tmux.until { |lines| lines.item_count.zero? }
    tmux.until { |lines| lines.last.include?('> foo') }
    tmux.send_keys 'C-a', 'bar'
    tmux.until { |lines| lines.last.include?('> barfoo') }
    tmux.send_keys :Space
    tmux.until { |lines| lines.last == '>' }
  end

  def test_clear_selection
    tmux.send_keys %(seq 100 | #{FZF} --multi --bind space:clear-selection), :Enter
    tmux.until { |lines| lines.match_count == 100 }
    tmux.send_keys :Tab
    tmux.until { |lines| lines[-2].include?('(1)') }
    tmux.send_keys 'foo'
    tmux.until { |lines| lines.match_count.zero? }
    tmux.until { |lines| lines[-2].include?('(1)') }
    tmux.send_keys :Space
    tmux.until { |lines| lines.match_count.zero? }
    tmux.until { |lines| !lines[-2].include?('(1)') }
  end

  def test_backward_delete_char_eof
    tmux.send_keys "seq 1000 | #{fzf "--multi --jump-labels 12345 --bind 'bs:backward-delete-char/eof'"}", :Enter
    tmux.until { |lines| lines[-2] == '  1000/1000' }
    tmux.send_keys '11'
    tmux.until { |lines| lines[-1] == '> 11' }
    tmux.send_keys :BSpace
    tmux.until { |lines| lines[-1] == '> 1' }
    tmux.send_keys :BSpace
    tmux.until { |lines| lines[-1] == '>' }
    tmux.send_keys :BSpace
    tmux.prepare
  end

end

module TestShell
  def setup
    super
  end

  def teardown
    @tmux.kill
  end

  def set_var(name, val)
    tmux.prepare
    tmux.send_keys "export #{name}='#{val}'", :Enter

Review comment (suggestion):
`jump-labels` and `multi` are irrelevant to the test, so let's remove them.

Code after:

  def test_clear_query
    tmux.send_keys %(: | #{FZF} --query foo --bind space:clear-query), :Enter
    tmux.until { |lines| lines.item_count.zero? }
    tmux.until { |lines| lines.last.include?('> foo') }
    tmux.send_keys 'C-a', 'bar'
    tmux.until { |lines| lines.last.include?('> barfoo') }
    tmux.send_keys :Space
    tmux.until { |lines| lines.last == '>' }
  end

  def test_clear_selection
    tmux.send_keys %(seq 100 | #{FZF} --multi --bind space:clear-selection), :Enter
    tmux.until { |lines| lines.match_count == 100 }
    tmux.send_keys :Tab
    tmux.until { |lines| lines[-2].include?('(1)') }
    tmux.send_keys 'foo'
    tmux.until { |lines| lines.match_count.zero? }
    tmux.until { |lines| lines[-2].include?('(1)') }
    tmux.send_keys :Space
    tmux.until { |lines| lines.match_count.zero? }
    tmux.until { |lines| !lines[-2].include?('(1)') }
  end

  def test_backward_delete_char_eof
    tmux.send_keys "seq 1000 | #{fzf "--bind 'bs:backward-delete-char/eof'"}", :Enter
    tmux.until { |lines| lines[-2] == '  1000/1000' }
    tmux.send_keys '11'
    tmux.until { |lines| lines[-1] == '> 11' }
    tmux.send_keys :BSpace
    tmux.until { |lines| lines[-1] == '> 1' }
    tmux.send_keys :BSpace
    tmux.until { |lines| lines[-1] == '>' }
    tmux.send_keys :BSpace
    tmux.prepare
  end

end

module TestShell
  def setup
    super
  end

  def teardown
    @tmux.kill
  end

  def set_var(name, val)
    tmux.prepare
    tmux.send_keys "export #{name}='#{val}'", :Enter